如何把 NumPy 数组转换成 TensorFlow 的 tensor?
How can you convert a NumPy array into a TensorFlow tensor?
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: easy
标签: TensorFlow, NumPy, API
参考答案摘要
可使用 tf.convert_to_tensor: import tensorflow as tf import numpy as np arr = np.array([1, 2, 3]) t = tf.convert_to_tensor(arr, dtype=tf.float32) print(t)
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。