TensorFlow中 将tensor 转为 numpy数组


Session.run或eval返回的任何张量都是NumPy数组,参考代码如下:

print(tf.Session().run(tf.constant([1,2,3,4,5,6])))

或者

sess = tf.Session()
with sess.as_default():
    print(tf.constant([1,2,3,4,5,6]).eval())
GPU云服务器(支持Jupyter)

内置Jupyter、Pycharm的GPU服务器,访问淘宝店


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM