January 2019
Intermediate to advanced
342 pages
9h 17m
English
The model can be trained with the Adam optimizer, since it reliably provides stable convergence. Since RNNs are prone to exploding gradient problems (although this is not so problematic for LSTMs), it is better to clip the gradients if they become too large. The given model can be defined and compiled with the Adam optimizer and sparse_categorical_crossentropy, as shown in the following code block:
def create_model(self): _model_ = self.define_model() adam = Adam(lr=self.learning_rate,clipvalue=5.0) _model_.compile(optimizer=adam,loss='sparse_categorical_crossentropy') return _model_
Now that we have looked at all the basic functions, the training function can be coded as follows:
def train_model(self,model,X_train,X_test,y_train,y_test): ...
Read now
Unlock full access