我目前处于需要训练此类网络的情况。
def model3():
#stride = 1
#dim = 40
#window_height = 5
#splits = ((40-5)+1)/1 = 18
next(test_generator())
next(train_generator(batch_size))
kernel_number = 200#int(math.ceil(splits))
list_of_input = [Input(shape = (window_height,total_frames_with_deltas,3)) for i in range(splits)]
list_of_conv_output = []
list_of_max_out = []
for i in range(splits):
list_of_conv_output.append(Conv2D(filters = kernel_number , kernel_size = (window_height,3), activation = 'relu')(list_of_input[i]))
list_of_max_out.append((MaxPooling2D(pool_size=((1,11)))(list_of_conv_output[i])))
merge = keras.layers.concatenate(list_of_max_out)
print merge.shape
reshape = Reshape((total_frames/total_frames,-1))(merge)
dense1 = Dense(units = 1000, activation = 'relu', name = "dense_1")(reshape)
dense2 = Dense(units = 1000, activation = 'relu', name = "dense_2")(dense1)
dense3 = Dense(units = 145 , activation = 'softmax', name = "dense_3")(dense2)
#dense4 = Dense(units = 1, activation = 'linear', name = "dense_4")(dense3)
我希望可以看到我有33个输入,每个输入都有自己的卷积和池化层。问题是每个卷积和池化层具有相同的参数,并且我可以看到可以改变每个卷积和池对的唯一方法是,如果我当时定义了每个单独的层 - 而不是定义它在for循环中。
有没有一种干净的方法来实现这一点,而不必编写许多代码行,或者我定义每个代码的长列表 - 但更容易访问每个元素并更改它们。