【发布时间】:2021-01-10 08:57:48
【问题描述】:
最近在研究用tensorflow进行视频图像处理的3d卷积。
我用教程博客制作模型。但我想制作我的自定义数据集。我的输入图像的形状是(128,128,3),我想制作图像立方体(128,128,100,3)。我使用 tensorflow.data.dataset 并尝试通过回忆我用于 2d 卷积的记忆来创建一个映射函数。由于使用 NumPy 时内存不足,我想使用包含 (Number of image cube, 100) 和 tf.data.dataset 映射函数的路径来对多维数据集进行映像。
我尝试使用如下代码
def load_image(path):
images = []
for i, p in enumerate(path):
image_string = tf.io.read_file(p)
image = tf.io.decode_jpeg(p, channels=3)
image = tf.reshape(image, [128,128,1,3])
image = image / 255
images.append(image)
image_block = tf.concat(images, axis=2)
return image_block
train_data = tf.data.Dataset.from_tensor_slices(total_files) # shape (1077,100)
train_data = train_data.map(load_images, num_parallel_calls=tf.data.experimental.AUTOTUNE)
但是有张量的形状改变的错误。我也使用 .assign 使用 tf.Variable 但有类似的错误。
如何用路径制作3d卷积的输入图像立方体???我使用 tensorflow 2.0。
【问题讨论】:
-
你能显示完整的错误信息吗?
-
peratorNotAllowedInGraphError: 在图形执行中不允许迭代
tf.Tensor。使用 Eager 执行或使用 @tf.function 装饰此函数。
标签: tensorflow conv-neural-network