从Pandas数据框转换为TensorFlow张量对象 [英] Converting from Pandas dataframe to TensorFlow tensor object

查看:1371
本文介绍了从Pandas数据框转换为TensorFlow张量对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍然对Python,机器学习和TensorFlow还是陌生的,但我会尽全力以最快的速度领先.我可以帮忙.

I'm still new to Python, Machine Learning and TensorFlow, but doing my best to jump right in head-first. I could use some help though.

我的数据当前在Pandas数据框中.如何将其转换为TensorFlow对象?我已经尝试过

My data is currently in a Pandas dataframe. How can I convert this to TensorFlow object? I've tried

dataVar_tensor = tf.constant(dataVar)
depth_tensor = tf.constant(depth)

但是,我收到错误[15780 rows x 9 columns] - got shape [15780, 9], but wanted [].

我确定这可能是一个简单的问题,但是我真的可以使用帮助.

I'm sure this is probably a straightforward question, but I could really use the help.

非常感谢

ps.我在Windows 10上使用Anaconda Python 3.5运行tensorflow 0.12

ps. I'm running tensorflow 0.12 with Anaconda Python 3.5 on Windows 10

推荐答案

我已经使用df.values

现在,使用

dataVar_tensor = tf.constant(dataVar, dtype = tf.float32, shape=[15780,9])
depth_tensor = tf.constant(depth, 'float32',shape=[15780,1])

似乎可以正常工作.我不能说它一定能做到,因为我还有其他障碍需要克服才能使我的代码正常工作,但是希望这是朝着正确方向迈出的一步.谢谢您的帮助

seems to work. I can't say it does definitively because I have other hurdles to overcome to get my code working, but it's hopefully a step in the right direction. Thanks for all your help

顺便说一句,在下一个问题

As an aside, my trials of getting the tutorial to work on my own data are continued in my next question Converting TensorFlow tutorial to work with my own data

这篇关于从Pandas数据框转换为TensorFlow张量对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆