Python 验证模型时,Keras 中的verbose 有什么用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47902295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the use of verbose in Keras while validating the model?
提问by rakesh
I'm running the LSTM model for the first time. Here is my model:
我是第一次运行 LSTM 模型。这是我的模型:
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?
训练模型时verbose有什么用?
回答by Ankit
Check documentation for model.fit here.
在此处查看 model.fit 的文档。
By setting verbose 0, 1 or 2 you just say how do you want to 'see' the training progress for each epoch.
通过设置详细的 0、1 或 2,您只需说明您想如何“查看”每个时期的训练进度。
verbose=0
will show you nothing (silent)
verbose=0
什么都不给你看(沉默)
verbose=1
will show you an animated progress bar like this:
verbose=1
将向您显示一个动画进度条,如下所示:
verbose=2
will just mention the number of epoch like this:
verbose=2
只会提到这样的时代数:
回答by Ashok Kumar Jayaraman
verbose: Integer
. 0, 1, or 2. Verbosity mode.
verbose: Integer
. 0、1 或 2。详细模式。
Verbose=0 (silent)
详细=0(静音)
Verbose=1 (progress bar)
Verbose=1(进度条)
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)
Verbose=2(每个纪元一行)
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
回答by Hugo Bevilacqua
For verbose
> 0, fit
method logs:
对于verbose
> 0,fit
方法日志:
- loss: value of loss function for your training data
- acc: accuracy value for your training data.
- loss: 训练数据的损失函数值
- acc:训练数据的准确度值。
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:
如果validation_data
或validation_split
参数不为空,fit
方法记录:
- val_loss: value of loss function for your validation data
- val_acc: accuracy value for your validation data
- val_loss:验证数据的损失函数值
- val_acc:验证数据的准确度值
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.
例如,使用verbose
while 训练模型有助于检测过度拟合,如果您acc
不断改进而您val_acc
变得更糟,则会发生过度拟合。
回答by Ashiq Imran
By default verbose = 1,
默认情况下详细 = 1,
verbose = 1, which includes both progress bar and one line per epoch
verbose = 1,其中包括进度条和每个 epoch 的一行
verbose = 0, means silent
verbose = 0,表示无声
verbose = 2, one line per epoch i.e. epoch no./total no. of epochs
详细 = 2,每个纪元一行,即纪元编号/总编号。时代的