I'm running the LSTM model for the first time. Here is my model:
opt = Adam(0.002)
inp = Input(...)
print(inp)
x = Embedding(....)(inp)
x = LSTM(...)(x)
x = BatchNormalization()(x)
pred = Dense(5,activation='softmax')(x)
model = Model(inp,pred)
model.compile(....)
idx = np.random.permutation(X_train.shape[0])
model.fit(X_train[idx], y_train[idx], nb_epoch=1, batch_size=128, verbose=1)
What is the use of verbose while training the model?
This question is related to
python
deep-learning
keras
verbose
For verbose
> 0, fit
method logs:
Note: If regularization mechanisms are used, they are turned on to avoid overfitting.
if validation_data
or validation_split
arguments are not empty, fit
method logs:
Note: Regularization mechanisms are turned off at testing time because we are using all the capabilities of the network.
For example, using verbose
while training the model helps to detect overfitting which occurs if your acc
keeps improving while your val_acc
gets worse.
By default verbose = 1,
verbose = 1, which includes both progress bar and one line per epoch
verbose = 0, means silent
verbose = 2, one line per epoch i.e. epoch no./total no. of epochs
The order of details provided with verbose flag are as
Less details.... More details
0 < 2 < 1
Default is 1
For production environment, 2 is recommended
verbose: Integer
. 0, 1, or 2. Verbosity mode.
Verbose=0 (silent)
Verbose=1 (progress bar)
Train on 186219 samples, validate on 20691 samples
Epoch 1/2
186219/186219 [==============================] - 85s 455us/step - loss: 0.5815 - acc:
0.7728 - val_loss: 0.4917 - val_acc: 0.8029
Train on 186219 samples, validate on 20691 samples
Epoch 2/2
186219/186219 [==============================] - 84s 451us/step - loss: 0.4921 - acc:
0.8071 - val_loss: 0.4617 - val_acc: 0.8168
Verbose=2 (one line per epoch)
Train on 186219 samples, validate on 20691 samples
Epoch 1/1
- 88s - loss: 0.5746 - acc: 0.7753 - val_loss: 0.4816 - val_acc: 0.8075
Train on 186219 samples, validate on 20691 samples
Epoch 1/1
- 88s - loss: 0.4880 - acc: 0.8076 - val_loss: 0.5199 - val_acc: 0.8046
Source: Stackoverflow.com