Я хочу изменить размер изображения в нейронной сети и не предоставляю форму ввода. Является ли это возможным? Мой последний код:
def exp_no_input_shape():
kernel_size = (3, 3)
a = tf.placeholder(tf.int32)
b = tf.placeholder(tf.int32)
inp = Input(shape=[a, b, 3])
layer1 = Conv2D(3, kernel_size, strides=(2, 2), padding='same', activation='relu')(inp)
resize_layer = tf.image.resize_images(layer1, [tf.shape(layer1).eval(session=tf.compat.v1.Session())[0]*2, tf.shape(layer1).eval(session=tf.compat.v1.Session())[1]*2], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
layer2 = Conv2D(3, kernel_size, padding='same', activation='relu')(resize_layer)
return Model(inp, layer2)
Выдает ошибку: Error converting shape to a TensorShape: int() argument must be a string, a bytes-like object or a number, not 'Tensor'.
Кроме того, я пробовал это раньше:
def exp_no_input_shape():
kernel_size = (3, 3)
inp = Input(shape=[None, None, 3])
layer1 = Conv2D(3, kernel_size, strides=(2, 2), padding='same', activation='relu')(inp)
resize_layer = tf.image.resize_images(layer1, [tf.shape(layer1).eval(session=tf.compat.v1.Session())[0]*2, tf.shape(layer1).eval(session=tf.compat.v1.Session())[1]*2], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
layer2 = Conv2D(3, kernel_size, padding='same', activation='relu')(resize_layer)
return Model(inp, layer2)
Выдает ошибку: You must feed a value for placeholder tensor 'input_1' with dtype float and shape [?,?,?,3]