Python tensorflow.python.keras.layers.LSTM Examples
The following are 5
code examples of tensorflow.python.keras.layers.LSTM().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow.python.keras.layers
, or try the search function
.
Example #1
Source File: plot_segment_rep.py From seglearn with BSD 3-Clause "New" or "Revised" License | 6 votes |
def crnn_model(width=100, n_vars=6, n_classes=7, conv_kernel_size=5, conv_filters=3, lstm_units=3): input_shape = (width, n_vars) model = Sequential() model.add(Conv1D(filters=conv_filters, kernel_size=conv_kernel_size, padding='valid', activation='relu', input_shape=input_shape)) model.add(Conv1D(filters=conv_filters, kernel_size=conv_kernel_size, padding='valid', activation='relu')) model.add(LSTM(units=lstm_units, dropout=0.1, recurrent_dropout=0.1)) model.add(Dense(n_classes, activation="softmax")) model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) return model # load the data
Example #2
Source File: plot_model_selection2.py From seglearn with BSD 3-Clause "New" or "Revised" License | 6 votes |
def crnn_model(width=100, n_vars=6, n_classes=7, conv_kernel_size=5, conv_filters=2, lstm_units=2): # create a crnn model with keras with one cnn layers, and one rnn layer input_shape = (width, n_vars) model = Sequential() model.add(Conv1D(filters=conv_filters, kernel_size=conv_kernel_size, padding='valid', activation='relu', input_shape=input_shape)) model.add(LSTM(units=lstm_units, dropout=0.1, recurrent_dropout=0.1)) model.add(Dense(n_classes, activation="softmax")) model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) return model # load the data
Example #3
Source File: plot_nn_training_curves.py From seglearn with BSD 3-Clause "New" or "Revised" License | 6 votes |
def crnn_model(width=100, n_vars=6, n_classes=7, conv_kernel_size=5, conv_filters=3, lstm_units=3): input_shape = (width, n_vars) model = Sequential() model.add(Conv1D(filters=conv_filters, kernel_size=conv_kernel_size, padding='valid', activation='relu', input_shape=input_shape)) model.add(LSTM(units=lstm_units, dropout=0.1, recurrent_dropout=0.1)) model.add(Dense(n_classes, activation="softmax")) model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) return model ############################################## # Setup ############################################## # load the data
Example #4
Source File: sequence.py From DeepCTR with Apache License 2.0 | 6 votes |
def build(self, input_shape): if len(input_shape) != 3: raise ValueError( "Unexpected inputs dimensions %d, expect to be 3 dimensions" % (len(input_shape))) self.fw_lstm = [] self.bw_lstm = [] for _ in range(self.layers): self.fw_lstm.append( LSTM(self.units, dropout=self.dropout_rate, bias_initializer='ones', return_sequences=True, unroll=True)) self.bw_lstm.append( LSTM(self.units, dropout=self.dropout_rate, bias_initializer='ones', return_sequences=True, go_backwards=True, unroll=True)) super(BiLSTM, self).build( input_shape) # Be sure to call this somewhere!
Example #5
Source File: sequence.py From icme2019 with MIT License | 5 votes |
def build(self, input_shape): if len(input_shape) != 3: raise ValueError( "Unexpected inputs dimensions %d, expect to be 3 dimensions" % (len(input_shape))) self.fw_lstm = [] self.bw_lstm = [] for _ in range(self.layers): self.fw_lstm.append(LSTM(self.units, dropout=self.dropout, bias_initializer='ones', return_sequences=True, unroll=True)) self.bw_lstm.append(LSTM(self.units, dropout=self.dropout, bias_initializer='ones', return_sequences=True, go_backwards=True, unroll=True)) super(BiLSTM, self).build( input_shape) # Be sure to call this somewhere!