【问题标题】:what's the appropriate placeholder for my input我的输入的合适占位符是什么
【发布时间】:2019-01-15 15:03:32
【问题描述】:

我有一个 1k 行和 14 列的数据框,其中包含如下所示的 numpy 数组。

这里是 2 行 3 列的子集:

[5,4,74,-12] [  78,1,2,-9]    [5 ,1,1,2] 

[10,4,4,-1]  [  8,15,21,-19]  [1,1,0,0] 

每个单元格都是一个形状为(4,1)的numpy数组。

我找不到正确的占位符来输入我的整个数据框,因为它需要按行批处理。

谁有想法?

我试过这个来为我的数据框找到合适的占位符,但它不正确:

x = tf.placeholder(tf.int32,[None,14],name='x') 

with tf.Session() as sess:
     print(sess.run(x,feed_dict={x:Data}))

It gives ValueError: setting an array element with a sequence.  

请问有人有想法吗?

【问题讨论】:

    标签: dataframe tensorflow input model placeholder


    【解决方案1】:

    您没有指定数据可用的格式,所以我假设它是一个 numpy 数组。在这种情况下,您可以这样做:

    n_columns = 14
    n_elements_per_column = 4
    
    x = tf.placeholder(tf.int32, [None, n_columns, n_elements_per_column], name='x') 
    
    with tf.Session() as sess:
         print(sess.run(x,feed_dict={x:Data}))
    

    【讨论】:

    • 我在使用序列设置数组元素时仍然遇到同样的错误。
    • @LY-: 你能发布你的数据变量吗?它似乎与纯 numpy 数组不同。
    猜你喜欢
    • 1970-01-01
    • 2013-11-19
    • 1970-01-01
    • 2013-08-13
    • 1970-01-01
    • 2011-07-28
    • 2016-11-16
    • 1970-01-01
    • 2018-03-07
    相关资源
    最近更新 更多