私は私に層という変数を返す関数を持っています。 jpeg。保存テンソルtf.map_fnとJPEG画像として - フォーマットの画像 - パイソン/ TensorFlow
これまでのところ、私はこのことを考えてきました:
# Reshape into tf.image.encode_jpeg format
images = tf.image.convert_image_dtype(layer, tf.uint8)
train_batch_size = 300
とセッション= tf.Session(中)を
images_encode = tf.map_fn(lambda x: tf.image.encode_jpeg(x), images, dtype=tf.uint8) # There was no error in this line, is it right?
私の疑問は今、それらを保存するように設定する方法ですか?
私はこれを試してみた:
# That means it will only scroll through my 300 images
# And it's these 300 images that I want to save
x_batch, y_true_batch = next_batch_size(train_batch_size)
feed_dict_train = {x: x_batch, y_true: y_true_batch}
result = session.run(images_encode, feed_dict=feed_dict_train)
format_str = ('%s.jpeg')
fr = format_str % datetime.now()
f = open(fr, "wb+")
f.write(result.eval())
f.close()
しかし、私は次のエラーを取得しています:
InvalidArgumentError (see above for traceback): TensorArray dtype is uint8 but Op is trying to write dtype string.
[[Node: map_5/while/TensorArrayWrite/TensorArrayWriteV3 = TensorArrayWriteV3[T=DT_STRING, _class=["loc:@map_5/TensorArray_1"], _device="/job:localhost/replica:0/task:0/cpu:0"](map_5/while/TensorArrayWrite/TensorArrayWriteV3/Enter, map_5/while/Identity, map_5/while/EncodeJpeg, map_5/while/Identity_1)]]
マイプレースホルダは、次のとおりです。
# Placeholder variable for the input images
x = tf.placeholder(tf.float32, shape=[None, img_size_flat], name='x')
# Reshape 'x'
x_image = tf.reshape(x, [-1, img_size, img_size, num_channels])
# Placeholder variable for the true labels associated with the images
y_true = tf.placeholder(tf.float32, shape=[None, num_classes], name='y_true')
: これは、ノイズの多い画像を与える:タイプは
tf.string
する必要があります。 – Patwie@Patwie、遅れて申し訳ありません、私は最近忙しかった! – QuestionsStackOverflow