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

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.

主站蜘蛛池模板: 利川市| 武邑县| 班玛县| 原平市| 卫辉市| 定陶县| 石城县| 拉萨市| 遵义市| 吉安县| 武定县| 新宁县| 郧西县| 黑龙江省| 南宫市| 江北区| 方山县| 尼玛县| 盘锦市| 太康县| 芮城县| 鄱阳县| 丹江口市| 仁化县| 永寿县| 修水县| 郁南县| 扶风县| 修文县| 新龙县| 贞丰县| 石阡县| 罗田县| 宁明县| 曲麻莱县| 乌鲁木齐市| 岳西县| 拉萨市| 泰安市| 中江县| 故城县|