- Deep Learning with PyTorch Quick Start Guide
- David Julian
- 161字
- 2021-07-02 15:00:10
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.
- 大數(shù)據(jù)戰(zhàn)爭:人工智能時代不能不說的事
- 電力自動化實用技術(shù)問答
- Julia 1.0 Programming
- JMAG電機電磁仿真分析與實例解析
- 空間傳感器網(wǎng)絡(luò)復(fù)雜區(qū)域智能監(jiān)測技術(shù)
- 傳感器與物聯(lián)網(wǎng)技術(shù)
- Kubernetes for Developers
- 聊天機器人:入門、進階與實戰(zhàn)
- 悟透AutoCAD 2009案例自學(xué)手冊
- Hadoop應(yīng)用開發(fā)基礎(chǔ)
- Salesforce Advanced Administrator Certification Guide
- Mastering Geospatial Analysis with Python
- Getting Started with Tableau 2018.x
- 巧學(xué)活用Linux
- 暗戰(zhàn)強人:黑客攻防入門全程圖解