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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:25:55  来源:igfitidea点击:

What is the use of verbose in Keras while validating the model?

pythondeep-learningkerasverbose

提问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=0will show you nothing (silent)

verbose=0什么都不给你看(沉默)

verbose=1will show you an animated progress bar like this:

verbose=1将向您显示一个动画进度条,如下所示:

progres_bar

进度条

verbose=2will just mention the number of epoch like this:

verbose=2只会提到这样的时代数:

enter image description here

在此处输入图片说明

回答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, fitmethod 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_dataor validation_splitarguments are not empty, fitmethod logs:

如果validation_datavalidation_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 verbosewhile training the model helps to detect overfitting which occurs if your acckeeps improving while your val_accgets worse.

例如,使用verbosewhile 训练模型有助于检测过度拟合,如果您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,每个纪元一行,即纪元编号/总编号。时代的