我是靠谱客的博主 激动音响,这篇文章主要介绍tensor转换为list_tensor numpy.array panda.dataframe list等数据类型的转换,现在分享给大家,希望可以做个参考。

TensorFlow将给定值转换为张量

tf.convert_to_tensor

此函数将各种类型的 Python 对象转换为 Tensor 对象.它接受 Tensor 对象,numpy 数组,Python 列表和 Python 标量

8f900a89c6347c561fdf2122f13be562.png

961ddebeb323a10fe0623af514929fc1.png

convert_to_tensor (

value ,

dtype=None ,

name=None ,

preferred_dtype=None

)

输入格式类型

importnumpy as npdefmy_func(arg):

arg= tf.convert_to_tensor(arg, dtype=tf.float32)return tf.matmul(arg, arg) +arg#The following calls are equivalent.

value_1 = my_func(tf.constant([[1.0, 2.0], [3.0, 4.0]]))

value_2= my_func([[1.0, 2.0], [3.0, 4.0]])

value_3= my_func(np.array([[1.0, 2.0

最后

以上就是激动音响最近收集整理的关于tensor转换为list_tensor numpy.array panda.dataframe list等数据类型的转换的全部内容,更多相关tensor转换为list_tensor内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(125)

评论列表共有 0 条评论

立即
投稿
返回
顶部