tensorflow.python.ops 中的 array_op, 类似与numpy中的np.array
示例:
from tensorflow.python.framework import constant_op
from tensorflow.python.ops import array_ops
const0 = tf.constant(10)
const1 = constant_op.constant([10,10,10])
array_ops_result0 = array_ops.expand_dims(const0,axis=0)
array_ops_result1 = array_ops.expand_dims(const1,axis=0)
print("array_ops_result0 = ",array_ops_result0)
print("array_ops_result1 = ",array_ops_result1)
结果:
array_ops_result0 = Tensor("ExpandDims:0", shape=(1,), dtype=int32)
array_ops_result1 = Tensor("ExpandDims_1:0", shape=(1, 3), dtype=int32)
随感:感觉tensorflow在 tensorflow.python.ops模块把python的所有功能都用tensorflow重新复现了一遍。
所以,pytorch是深度学习领域的numpy,tensorflow是另一个python.
本文探讨了TensorFlow和PyTorch在深度学习领域的应用。通过示例展示了TensorFlow如何在tensorflow.python.ops模块中实现类似NumPy的功能,如使用expand_dims操作。作者认为TensorFlow几乎重写了Python的所有功能,而PyTorch则被比喻为深度学习领域的NumPy,TensorFlow则像是另一个Python。
3729

被折叠的 条评论
为什么被折叠?



