【发布时间】:2018-03-21 11:36:10
【问题描述】:
在以下代码中:
import tensorflow as tf
import numpy as np
with tf.Session():
input_features = tf.constant(np.reshape([2, 1, 1, 2], (1, 4)).astype(np.float32))
print(input_features)
weights = tf.constant(np.random.randn(4, 2).astype(np.float32))
output = tf.matmul(input_features, weights)
print("Input:")
print(input_features.eval())
print("Weights:")
print(weights.eval())
print("Output:")
print(output.eval())
当它调用print(weights.eval()) 时,将计算权重。当它调用output.eval()时,会重新计算权重,还是使用之前调用的缓存值?
【问题讨论】:
标签: python tensorflow constants