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

Default value initialization

There are many cases where we need to initialize torch tensors to default values. Here, we create three 2 x 3 tensors, filling them with zeros, ones, and random floating point numbers:

An important point to consider when we are initializing random arrays is the so-called seed of reproducibility. See what happens when you run the preceding code several times. You get a different array of random numbers each time. Often in machine learning, we need to be able to reproduce results. We can achieve this by using a random seed. This is demonstrated in the following code:

Notice that when you run this code many times, the tensor values stay the same. If you remove the seed by deleting the first line, the tensor values will be different each time the code is run. It does not matter what number you use to seed the random number generator, as long as it is consistently, achieves reproducible results.

主站蜘蛛池模板: 饶平县| 涿州市| 平原县| 化德县| 武鸣县| 佛冈县| 万宁市| 台南市| 景谷| 藁城市| 手游| 吴桥县| 蓬莱市| 含山县| 马边| 红河县| 孝感市| 土默特左旗| 正蓝旗| 合江县| 巴里| 濮阳市| 丰镇市| 固镇县| 瑞昌市| 金沙县| 南溪县| 盈江县| 施秉县| 襄城县| 无棣县| 应用必备| 常熟市| 阳江市| 岳阳县| 封丘县| 涿州市| 大兴区| 黄平县| 永寿县| 固原市|