- Deep Learning with PyTorch Quick Start Guide
- David Julian
- 157字
- 2021-07-02 15:00:11
In place operations
It is important to understand the difference between in place and assignment operations. When, for example, we use transpose(x), a value is returned but the value of x does not change. In all the examples up until now, we have been performing operations by assignment. That is, we have been assigning a variable to the result of an operation, or simply printing it to the output, as in the preceding example. In either case, the original variable remains untouched. Alternatively, we may need to apply an operation in place. We can, of course, assign a variable to itself, such as in x = x.transpose(0,1); however, a more convenient way to do this is with in place operations. In general, in place operations in PyTorch have a trailing underscore. For an example, see the following code:

As another example, here is the linear function we started this chapter with using in place operations on y:

- 后稀缺:自動(dòng)化與未來工作
- Canvas LMS Course Design
- Verilog HDL數(shù)字系統(tǒng)設(shè)計(jì)入門與應(yīng)用實(shí)例
- 空間傳感器網(wǎng)絡(luò)復(fù)雜區(qū)域智能監(jiān)測技術(shù)
- 最后一個(gè)人類
- Hands-On Linux for Architects
- Moodle Course Design Best Practices
- 運(yùn)動(dòng)控制系統(tǒng)應(yīng)用與實(shí)踐
- 基于企業(yè)網(wǎng)站的顧客感知服務(wù)質(zhì)量評價(jià)理論模型與實(shí)證研究
- INSTANT Munin Plugin Starter
- Windows安全指南
- Python文本分析
- AVR單片機(jī)工程師是怎樣煉成的
- 電動(dòng)汽車驅(qū)動(dòng)與控制技術(shù)
- 西門子S7-1200/1500 PLC從入門到精通