tf.placeholder用法

import tensorflow as tf
import numpy as np

# 以下两种shape方法都是可以的[] 和 ()
# x = tf.placeholder(tf.float32, shape=[1024, 1024])
x = tf.placeholder(tf.float32, shape=(1024, 1024))
y = tf.matmul(x, x)
with tf.Session() as sess:
    rand_array = np.random.rand(1024, 1024)
    print(sess.run(y, feed_dict={x: rand_array}))  # Will succeed.

猜你喜欢

转载自blog.csdn.net/qq_36201400/article/details/108534928