该模型的目标是通过与视频输入相关联的单词对视频输入进行分类。每个输入具有维度45帧、1个灰色颜色通道、100个像素行和150个像素列(45、1、100、150),而每个对应的输出是3个可能字(例如,=> 0、0、1)之一的一个热编码表示。
在编译模型的过程中,会出现以下错误:
ValueError: Dimensions must be equal, but are 1 and 3 for 'Conv2D_94' (op: 'Conv2D') with
input shapes: [?,100,150,1], [3,3,3,32].以下是用于训练模型的脚本:
video = Input(shape=(self.frames_per_sequence,
1,
self.rows,
self.columns))
cnn = InceptionV3(weights="imagenet",
include_top=False)
cnn.trainable = False
encoded_frames = TimeDistributed(cnn)(video)
encoded_vid = LSTM(256)(encoded_frames)
hidden_layer = Dense(output_dim=1024, activation="relu")(encoded_vid)
outputs = Dense(output_dim=class_count, activation="softmax")(hidden_layer)
osr = Model([video], outputs)
optimizer = Nadam(lr=0.002,
beta_1=0.9,
beta_2=0.999,
epsilon=1e-08,
schedule_decay=0.004)
osr.compile(loss="categorical_crossentropy",
optimizer=optimizer,
metrics=["categorical_accuracy"]) 发布于 2017-02-28 11:32:44
根据Keras中的Convolution2D,以下内容应该是输入和过滤器的形状。
shape of input = [batch, in_height, in_width, in_channels]
shape of filter = [filter_height, filter_width, in_channels, out_channels]所以,你得到的错误的意思是-
ValueError: Dimensions must be equal, but are 1 and 3 for 'Conv2D_94' (op: 'Conv2D') with
input shapes: [?,100,150,1], [3,3,3,32].[?,100,150,1]表示in_channels值为1,而[3,3,3,32]表示in_channels值为3。这就是为什么会出现错误- Dimensions must be equal, but are 1 and 3。
因此,您可以将过滤器的形状更改为[3, 3, 1, 32]。
https://stackoverflow.com/questions/42497925
复制相似问题