2017-04-10 67 views
1
import tensorflow as tf 
import pandas as pd 
url = 'http://vincentarelbundock.github.com/Rdatasets/csv/COUNT/medpar.csv' 
data=pd.read_csv(url) 
X=data[['type2', 'type3','hmo','white']] 
y=data[['los']] 
size=X.columns.shape 
B = tf.Variable(tf.random_uniform([1,size[0]])) 
a = tf.Variable(tf.zeros([1])) 
L=y * a 

我收到此錯誤:無效的廣播相比

Invalid broadcasting comparison [<tensorflow.python.ops.variables.Variable 
object at 0x000000000D7FD7B8>] with block values 

我的最終目標是使該功能:

L=y * tf.log(a)+y* 
(tf.matmul(x,B))*tf.log(1+a*tf.exp(tf.matmul(x,B)))+tf.log(tf.gamma(y+1/a))- 
tf.log(tf.gamma(1/a)) 

,但我得到上面這個錯誤在第一學期。

回答

0

經過一天或在此工作...

將y轉換爲矩陣。

y=data[['los']].as_matrix()