def buildnetwork(self): model = Sequential() model.add(lstm(20, dropout=0.2,input_shape = (self.seq_len, self.n_feature))) model.add(Dense(1, activation=None)) model.compile(loss='mean_squared_error', optimizer=Adagrad(lr=0.002,clipvalue=10), metrics=['mean_squared_error']) return model
def buildModel(shape, lstm_layers, lstm_units, dense_layers, dense_units): print(shape) model = Sequential() # LSTM layers for l in range(lstm_layers): if l == 0: this_shape = (shape[1], shape[2]) else: this_shape = (lstm_units, 1) if l == lstm_layers - 1: this_return = False else: this_return = True model.add(lstm(lstm_units, input_shape=this_shape, return_sequences=this_return)) model.add(Activation('relu')) # Dense layers for l in range(dense_layers): model.add(Dense(dense_units)) model.add(Activation('relu')) model.add(Dropout(0.1)) model.add(Dense(1)) model.compile(loss="mse", optimizer="adam", metrics=['mae']) model.summary() return model
def buildnetwork(self): model = Sequential() model.add( lstm(20, dropout=0.2, input_shape=(self.seq_len, self.n_feature))) model.add(Dense(1, activation=None)) model.compile(loss='mean_squared_error', optimizer=Adagrad(lr=0.002, clipvalue=10), metrics=['mean_squared_error']) return model
def make_default_model(self): self.model.add( lstm(128, input_shape=(self.input_shape[0], self.input_shape[1]))) self.model.add(Dropout(0.5)) self.model.add(Dense(32, activation='relu')) self.model.add(Dense(16, activation='tanh'))