【发布时间】:2017-07-26 15:22:14
【问题描述】:
我正在尝试建立一个基本的非线性回归模型来预测 FTSE350 公司的回报指数。
我不确定我的偏差项在维度方面应该是什么样的,以及我是否在计算方法中正确使用它:
w1 = tf.Variable(tf.truncated_normal([4, 10], mean=0.0, stddev=1.0, dtype=tf.float64))
b1 = tf.Variable(tf.constant(0.1, shape=[4,10], dtype = tf.float64))
w2 = tf.Variable(tf.truncated_normal([10, 1], mean=0.0, stddev=1.0, dtype=tf.float64))
b2 = tf.Variable(tf.constant(0.1, shape=[1], dtype = tf.float64))
def calculations(x, y):
w1d = tf.matmul(x, w1)
h1 = (tf.nn.sigmoid(tf.add(w1d, b1)))
h1w2 = tf.matmul(h1, w2)
activation = tf.add(tf.nn.sigmoid(tf.matmul(h1, w2)), b2)
error = tf.reduce_sum(tf.pow(activation - y,2))/(len(x))
return [ activation, error ]
我最初的想法是它应该和我的重量一样大,但我收到了这个错误:
ValueError: Dimensions must be equal, but are 251 and 4 for 'Add' (op: 'Add') with input shapes: [251,10], [4,10]
我尝试过不同的想法,但似乎没有成功。
(我的输入数据有4个特征)
我尝试的网络结构是输入层有 4 个神经元,隐藏层有 10 个神经元,稍后输出有 1 个神经元,但我觉得我的权重层也可能混淆了维度?
【问题讨论】:
标签: python python-2.7 tensorflow neural-network non-linear-regression