在每一层打印特征向量

时间:2018-02-08 16:47:32

标签: tensorflow neural-network

我正在https://www.tensorflow.org/get_started/get_started_for_beginners关注Tensorflow入门教程(我是Tensorflow的新手,因缺乏知识而道歉)。

我根据教程创建了神经网络并且运行正常,现在我想在训练期间打印每层的张量值。有一个简单的方法吗?

以下是代码:

# Fetch the data
(train_x, train_y), (test_x, test_y) = iris_data.load_data()

# Feature columns describe how to use the input.
my_feature_columns = []
for key in train_x.keys():
    my_feature_columns.append(tf.feature_column.numeric_column(key=key))

# Build 2 hidden layer DNN with 10, 10 units respectively.
classifier = tf.estimator.DNNClassifier(
    feature_columns=my_feature_columns,
    # Two hidden layers of 10 nodes each.
    hidden_units=[10, 10],
    # The model must choose between 3 classes.
    n_classes=3)

# Train the Model.
classifier.train(
    input_fn=lambda:iris_data.train_input_fn(train_x, train_y,
                                             args.batch_size),
    steps=args.train_steps)

# Evaluate the model.
....

理想情况下,我希望在每个时代之后获得隐藏层的价值。非常感谢任何见解。

0 个答案:

没有答案