【问题标题】:Invalid broadcasting comparison with block values- Tensorflow与块值的无效广播比较-Tensorflow
【发布时间】:2017-09-05 15:31:38
【问题描述】:
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))

但我在第一学期就遇到了上述错误。

【问题讨论】:

    标签: pandas tensorflow python-3.5


    【解决方案1】:

    经过一天或为此工作......

    将 y 转换为矩阵。

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

    【讨论】:

    • 在数据帧上使用.values
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-10
    • 1970-01-01
    • 1970-01-01
    • 2019-06-28
    • 2016-06-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多