首先创建一个常量张量x1 = tf.constant([1., 2., 3.], dtype=tf.float64) print(“x1:”,x1) x1这里就创建了一个一维的张量,包含3个元素,分别为1,2,3 dtype则指定了类型为64位浮点数 输出结果:x1: tf.Tensor([1. 2. 3.], shape=(3,), dtype=float64) x2 = tf.cast(x1, tf.int32) tf.cast 是 TensorFlow 中用于进行数据类型转换的函数。它接受