在tensorflow入门代码中:
import tensorflow as tf
import numpy as np
features = [tf.contrib.layers.real_valued_column("x", dimension=1)]
estimator = tf.contrib.learn.LinearRegressor(feature_columns=features)
x = np.array([1., 2., 3., 4.])
y = np.array([0., -1., -2., -3.])
input_fn = tf.contrib.learn.io.numpy_input_fn({"x":x}, y, batch_size=4, num_epochs=1000)
estimator.fit(input_fn=input_fn, steps=1000)
estimator.evaluate(input_fn=input_fn)
我知道batch_size是什么意思,但是当只有4个训练样例时,num_epochs和步骤分别是什么意思?
最佳答案 时代意味着使用您拥有的全部数据.
步骤意味着使用单个批次数据.
所以,n_steps =单个纪元// batch_size中的数据数量.
>步骤:训练模型的步骤数.如果没有,永远训练. ‘steps’以递增方式工作.如果您调用两次(步数= 10),则总共20个步骤进行训练.如果您不想有增量行为,请改为设置max_steps.如果设置,则max_steps必须为None.
> batch_size:要在输入上使用的小批量大小,默认为x的第一个维度.如果提供input_fn,则必须为None.
本文通过一个简单的线性回归示例介绍了TensorFlow的基本用法,重点解释了batch_size、num_epochs及steps参数的意义,帮助读者理解这些概念如何影响模型训练。
1021

被折叠的 条评论
为什么被折叠?



