IIS_2023_1/kondrashin_mikhail_lab_7/model.py

22 lines
668 B
Python
Raw Normal View History

2023-11-27 01:52:58 +04:00
from keras.models import Sequential
from keras.layers import Dense, Dropout, LSTM
from utils import N_UNITS, DROPOUT_RATE
class Model(Sequential):
def __init__(self, x, y):
super().__init__()
self.add(LSTM(N_UNITS, input_shape=(x.shape[1], x.shape[2]), return_sequences=True))
self.add(Dropout(DROPOUT_RATE))
self.add(LSTM(N_UNITS))
self.add(Dropout(DROPOUT_RATE))
self.add(Dense(y.shape[1], activation='softmax'))
def compile_model(self):
self.compile(loss='categorical_crossentropy', optimizer='adam')
def fit_model(self, x, y, batch_size, epochs):
self.fit(x, y, batch_size, epochs)