更新时间:2023-12-02 08:36:58
关于您为什么会收到错误的原始问题:
To your original question as to why you're getting the error:
Error when checking input: expected input_1 to have 2 dimensions, but got array with shape (32,)
代码中断的原因是因为您没有将.batch()
重新应用到dataset
变量,就像这样:
The reason your code breaks is because you haven't applied the .batch()
back to the dataset
variable, like so:
dataset = dataset.batch(10)
您只是打了dataset.batch()
.
这会中断,因为没有batch()
的输出张量不会被批处理,即您得到的形状是(32,)
而不是(1,32)
.
This breaks because without the batch()
the output tensors are not batched, i.e. you get shape (32,)
instead of (1,32)
.