Skip to content

Instantly share code, notes, and snippets.

@CVxTz
Created October 1, 2018 19:09
Show Gist options
  • Select an option

  • Save CVxTz/b32d572a58754ed4f7a3f19cdf7b619b to your computer and use it in GitHub Desktop.

Select an option

Save CVxTz/b32d572a58754ed4f7a3f19cdf7b619b to your computer and use it in GitHub Desktop.
def get_model_cnn():
nclass = 5
seq_input = Input(shape=(None, WINDOW_SIZE*30, 1))
base_model = get_base_model()
# for layer in base_model.layers:
# layer.trainable = False
encoded_sequence = TimeDistributed(base_model)(seq_input)
encoded_sequence = SpatialDropout1D(rate=0.01)(Convolution1D(128,
kernel_size=3,
activation="relu",
padding="same")(encoded_sequence))
encoded_sequence = Dropout(rate=0.05)(Convolution1D(128,
kernel_size=3,
activation="relu",
padding="same")(encoded_sequence))
#out = TimeDistributed(Dense(nclass, activation="softmax"))(encoded_sequence)
out = Convolution1D(nclass, kernel_size=3, activation="softmax", padding="same")(encoded_sequence)
model = models.Model(seq_input, out)
model.compile(optimizers.Adam(0.001), losses.sparse_categorical_crossentropy, metrics=['acc'])
model.summary()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment