语言都是相通的,学习过程中,可以和我的大前端js来比较比较。
1 张量
import tensorflow as tf
#创建张量
mammal = tf.Variable('Elephant',tf.string)
tf.print(tf.rank(mammal))
mystr = tf.Variable(['hello'],tf.string)
tf.print(tf.rank(mystr))
mymat = tf.Variable([[7],[11]],tf.int16)
tf.print(tf.rank(mymat))
tf.constant([1,2,3],dtype=tf.int16)
其实就是相当于js的变量
var a = 1;
console.log(a)
1 操作
#操作
#tf.strings
tf.strings.bytes_split('hello')
tf.strings.to_hash_bucket(['hello','world'],num_buckets=10)
#tf.debugging
a = tf.random.uniform((10,10))
tf.debugging.assert_equal(x=a.shape,y=(10,10))
#tf.random
a = tf.random.uniform(shape=(10,5),minval=0