我制作了一个DNN回归模型来预测我们在数据表中没有的结果,但我不能制作张量板.
此代码来自https://deeplearning4j.org/linear-regression.html 以及香港大学Sunghun Kim撰写的讲义.
import tensorflow as tf
import numpy as np
tf.set_random_seed(777) #for reproducibility
# data Import
xy = np.loadtxt('Training_Data.csv', delimiter=',', dtype=np.float32)
x_data = xy[:,0:-1]
y_data = xy[:,[-1]]
# Make sure the shape and data are OK
print(x_data.shape, x_data)
print(y_data.shape, y_data)
# input place holders
X = tf.placeholder(tf.float32, shape=[None, 2])
Y = tf.placeholder(tf.float32, shape=[None, 1])
# weight & bias for nn Layers
W1 = tf.get_variable("W1", shape=[2, 512],initializer=tf.contrib.layers.xavier_initializer())
b1 = tf.Variable(tf.random_normal([512]))
L1 = tf.nn.relu(tf.matmul(X, W1) + b1)
W2 = …Run Code Online (Sandbox Code Playgroud)