# 张量
import tensorflow as tf
"""
1. 定义:
tensorflow想象成一个n维 数组, 类型 tf.tensor, tensor里面有两个重要概念:
a. 类型:
dtype: 定义类型:
tf.placeholder(dtype = tf.float)
b. shape
2. 转换:
a. 类型转换:
tf.case(转换张量, 转换的类型)
b. 形状转换: shape
i.动态转换
reshape:
ii.静态转换
set_shape:
"""
def shape():
"""
show 张量的形状
:return:
"""
a = tf.constant(10) # 标量 shape=()
b = tf.constant([1, 2, 3, 4]) # 向量 shape=(4,)
c = tf.constant([[1, 2, 3], [4, 5, 6]]) # shape=(2, 3)
print(a)
print(b)
print(c)
return None
def create():
"""
创建张量
:return:
""&#
tensorflow张量
最新推荐文章于 2024-09-14 08:25:16 发布
本文深入探讨了TensorFlow中的张量概念,包括张量的创建、操作和使用。通过实例展示了张量如何在深度学习模型中作为基本数据结构进行计算,并讨论了其在Python环境下的交互方式。
摘要由CSDN通过智能技术生成