在构建模型时,我想在每个时期获得softmax
层的结果。
在这里,我想在以下模型的每个纪元的最后一层output
中获得结果的历史记录。
class DNN(object):
def __init__(self, config):
self.max_features = config['max_features']
self.num_batch = config['num_batch']
self.maxlen = config['maxlen']
self.embedding_dims = config['embedding_dims']
self.lstm_dims = config['lstm_dims']
self.hidden_dims = config['hidden_dims']
self.epochs = config['epochs']
self.classes = config['classes']
self.optimizer = config['optimizer']
def build_model(self):
input = Input(shape=(self.maxlen))
x = Dense(self.hidden_dims)(input)
x = Activation('relu')(x)
output = Dense(sef.classes)(x)
output = Activation('softmax')(output)
model = Model(inputs=input, outputs=output)
model.compile(loss= 'categorical_crossentropy', optimizer= 'adam')