官术网_书友最值得收藏!

Tensors generated from library functions

TensorFlow provides various functions to generate tensors with pre-populated values. The generated values from these functions can be stored in a constant or variable tensor. Such generated values can also be provided to the tensor constructor at the time of initialization.

As an example, let's generate a 1-D tensor that's been pre-populated with 100 zeros:

a=tf.zeros((100,))
print(tfs.run(a))

Some of the TensorFlow library functions that populate these tensors with different values at the time of their definition are listed as follows:

  • Populating all of the elements of a tensor with similar values: tf.ones_like()tf.ones(), tf.fill()tf.zeros(), andtf.zeros_like() 
  • Populating tensors with sequences: tf.range(),and tf.lin_space()
  • Populating tensors with a probability distribution: tf.random_uniform()tf.random_normal()tf.random_gamma(),and tf.truncated_normal()
主站蜘蛛池模板: 广南县| 石家庄市| 潞城市| 高阳县| 南昌县| 兴业县| 正定县| 乐清市| 贺州市| 大竹县| 景泰县| 策勒县| 溧阳市| 赣榆县| 丰镇市| 建德市| 巴彦县| 睢宁县| 呼图壁县| 金堂县| 黄冈市| 舒城县| 穆棱市| 翁牛特旗| 饶阳县| 张北县| 赫章县| 炉霍县| 偃师市| 壶关县| 民县| 米泉市| 焦作市| 紫金县| 瑞丽市| 潞城市| 武鸣县| 通渭县| 介休市| 平邑县| 普安县|