Machine learning 有人能给我解释一下TensorFlow的基本教程吗?

Machine learning 有人能给我解释一下TensorFlow的基本教程吗?,machine-learning,tensorflow,deep-learning,Machine Learning,Tensorflow,Deep Learning,我正在努力完成TensorFlow第一教程的第二部分: 基本用法: import tensorflow as tf # NumPy is often used to load, manipulate and preprocess data. import numpy as np # Declare list of features. We only have one real-valued feature. There are many # other types of columns th

我正在努力完成TensorFlow第一教程的第二部分:

基本用法:

import tensorflow as tf
# NumPy is often used to load, manipulate and preprocess data.
import numpy as np

# Declare list of features. We only have one real-valued feature. There are many
# other types of columns that are more complicated and useful.
features = [tf.contrib.layers.real_valued_column("x", dimension=1)]

# An estimator is the front end to invoke training (fitting) and evaluation
# (inference). There are many predefined types like linear regression,
# logistic regression, linear classification, logistic classification, and
# many neural network classifiers and regressors. The following code
# provides an estimator that does linear regression.
estimator = tf.contrib.learn.LinearRegressor(feature_columns=features)

# TensorFlow provides many helper methods to read and set up data sets.
# Here we use two data sets: one for training and one for evaluation
# We have to tell the function how many batches
# of data (num_epochs) we want and how big each batch should be.
x_train = np.array([1., 2., 3., 4.])
y_train = np.array([0., -1., -2., -3.])
x_eval = np.array([2., 5., 8., 1.])
y_eval = np.array([-1.01, -4.1, -7, 0.])
input_fn = tf.contrib.learn.io.numpy_input_fn({"x":x_train}, y_train,
                                              batch_size=4,
                                              num_epochs=1000)
eval_input_fn = tf.contrib.learn.io.numpy_input_fn(
    {"x":x_eval}, y_eval, batch_size=4, num_epochs=1000)

# We can invoke 1000 training steps by invoking the  method and passing the
# training data set.
estimator.fit(input_fn=input_fn, steps=1000)

# Here we evaluate how well our model did.
train_loss = estimator.evaluate(input_fn=input_fn)
eval_loss = estimator.evaluate(input_fn=eval_input_fn)
print("train loss: %r"% train_loss)
print("eval loss: %r"% eval_loss)
有人能给我解释一下,代码中的计算图隐藏在哪里? 我没有看到任何对tf.Graph或tf.Session的调用

features变量用于什么?数据似乎永远不会进入其中,因为数据提供程序是“input\u fn”。 如何查看会话的实际计算图和图形

为什么有两个地方是我设定年代数的地方?估计器.fit和numpy\u输入\u fn

如果我有两个不同的估计量,估计量1.fit…,步数=20,估计量2.fit…,步数=50? 我需要设置num_epochs=70吗?或者num_epochs=max20,50? 如果从fit调用,而不是从fit调用,输入如何控制线程数

tf.ot tf.Session的tf.Graph在哪里? Tensorflow为您创建默认的计算图。所以所有的 您在上面定义的变量和操作将处于默认状态 图表会话在估计器函数中定义。对于 示例estimator.fit创建受监控的培训课程

变量的功能是什么? 它用于初始化线性累加器模型。基于特征变量设置线性回归参数

在输入端设置的历元和估计器? input\u fn是一个队列,因此“input\u fn”中的历元表示有多少次 每个输入数据都需要弹出到队列中。“适合”度量的时代 每个输入需要在培训中使用多少次。因此,如果fit epoch大于queue epoch,则当队列结束时,训练将停止 停下来

两个不同估计器的队列大小。 “input_fn”历元应大于或等于 估计量中的年代