def test_conv1d_lstm(self):
from keras.layers import Conv1D, LSTM, Dense
model = Sequential()
# input_shape = (time_step, dimensions)
model.add(Conv1D(32,3,padding='same',input_shape=(10,8)))
# conv1d output shape = (None, 10, 32)
model.add(LSTM(24))
model.add(Dense(1, activation='sigmoid'))
input_names = ['input']
output_names = ['output']
spec = keras.convert(model, input_names, output_names).get_spec()
self.assertIsNotNone(spec)
self.assertTrue(spec.HasField('neuralNetwork'))
# Test the inputs and outputs
self.assertEquals(len(spec.description.input), len(input_names) + 2)
self.assertEquals(len(spec.description.output), len(output_names) + 2)
# Test the layer parameters.
layers = spec.neuralNetwork.layers
self.assertIsNotNone(layers[0].convolution)
self.assertIsNotNone(layers[1].simpleRecurrent)
self.assertIsNotNone(layers[2].innerProduct)
评论列表
文章目录