【发布时间】:2020-07-26 21:42:33
【问题描述】:
我对 TensorFlow 很陌生,我正在尝试使用 Dataset.from_generator 将视频程序加载到模型中,该模型从生成器内的文件名加载视频。我遇到的问题是这样的:
ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=5, found ndim=0. Full shape received: []
我不知道是什么原因造成的。
我的代码如下:
def video_gen():
inputs = np.array([e.strip().split(" ")[0] for e in label_desc])
labels = np.array([float(e.strip().split(" ")[1]) for e in label_desc])
for elem in range(len(inputs)):
yield (labels[elem], load_video(inputs[elem]))
dataset = tf.data.Dataset.from_generator(
video_gen,
(tf.float32, tf.float32),
(tf.TensorShape([]), tf.TensorShape([None]))
)
model = models.Sequential()
# variable length, set height, set width, 3 channels
model.add(layers.Input(shape=(None, 240, 320, 3)))
【问题讨论】:
标签: tensorflow keras tensorflow-datasets