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

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.

主站蜘蛛池模板: 宿州市| 大关县| 蚌埠市| 鄂托克旗| 兴安盟| 台南县| 荆州市| 元阳县| 武汉市| 天柱县| 朝阳市| 汉阴县| 西城区| 常熟市| 长宁县| 肥乡县| 周宁县| 平塘县| 荥经县| 鹤庆县| 辽宁省| 肇源县| 都江堰市| 邢台县| 班玛县| 志丹县| 永昌县| 乌兰县| 黄大仙区| 河西区| 张家川| 正定县| 太仓市| 内乡县| 宿迁市| 涿州市| 中卫市| 华宁县| 商城县| 禄劝| 陆川县|