为什么keras/python会奇怪地执行model.add(layers.reformate())呢?

2024-09-29 21:38:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个这样的神经网络:

model = Sequential()
model.add(Conv1D(100, 10, activation='relu', batch_input_shape=25)))
model.add(Conv1D(100, 10, activation='relu'))
model.add(MaxPool1D(3))
model.add(Conv1D(160, 10, activation='relu'))
model.add(GlobalAveragePooling1D())
model.add(layers.Dense(60))

enter image description here

我的生成器生成形状(20,60,1)的批目标。我有两个问题

  1. 我收到以下错误:

ValueError: Error when checking target: expected dense_1 to have 2 dimensions, but got array with shape (20, 60, 1)

当我这样做的时候

model.add(layers.Reshape((20,60,1)))

我得到以下错误:

ValueError: Cannot reshape a tensor with 1200 elements to shape [20,20,60,1] (24000 elements) for 'reshape_1/Reshape' (op: 'Reshape') with input shapes: [20,60], [4] and with input tensors computed as partial shapes: input[1] = [20,20,60,1].

为什么它要这样做呢

  1. 这是让神经网络在一批中的所有时间步中为我提供目标预测的正确方法吗?我想知道NN对每个时间步的预测是什么,而不仅仅是最后一个时间步。我的生成器批量生产20组(60x1)目标。每个时间步都有一个目标(其中有60个)。一批中每一组有60个输出的密集层是否正确

Tags: add目标inputmodellayers错误with时间

热门问题