【问题标题】:TensorFlow: Correct way of using steps in Stochastic Gradient DescentTensorFlow:在随机梯度下降中使用步骤的正确方法
【发布时间】:2018-10-10 10:39:12
【问题描述】:

我目前正在使用 TensorFlow 教程的 first_steps_with_tensor_flow.ipynb 笔记本来学习 TF 以实现 ML 模型。在笔记本中,他们使用了随机梯度下降 (SGD) 来优化损失函数。下面是my_input_function的sn-p:

def my_input_fn(features, targets, batch_size=1, shuffle=True, num_epochs=None):

这里可以看出batch_size为1。notebook使用包含17000个标注样本的房屋数据集进行训练。这意味着对于 SGD,我将拥有 17000 个批次。

LRmodel = linear_regressor.train(input_fn = lambda:my_input_fn(my_feature, targets), steps=100)

我有三个问题 -

  1. 为什么steps=100 在上面的linear_regressor.train 方法中?由于我们有 17000 个批次,而 ML 中的 steps 表示评估一个批次的计数,所以在 linear_regressor.train 方法中 steps = 17000 应该被初始化,对吧?

  2. 批次数是否等于 ML 中的步数/迭代数?

  3. 对于我的 17000 个示例,如果我保留我的 batch_size=100steps=500num_epochs=5,那么这个初始化意味着什么以及它与 170 个批次有什么关系?

【问题讨论】:

标签: python tensorflow machine-learning


【解决方案1】:

step是字面意思:意思是你刷新你的batch size中的参数;所以对于linear_regessor.train,它将为这个batch_size 1训练100次。
epoch的意思是刷新整个数据,你的集合里有17000个。

【讨论】:

    猜你喜欢
    • 2016-06-13
    • 2016-09-25
    • 2018-12-10
    • 2017-02-18
    • 2014-02-16
    • 2021-12-18
    • 2021-02-20
    • 2019-06-19
    • 1970-01-01
    相关资源
    最近更新 更多