《drive into deep learnning 》torch版学习笔记 tast01

1. 为什么jupyterlab的行首有 Python关于%matplotlib inline

1. https://zhuanlan.zhihu.com/p/34948525
(而%matplotlib具体作用是当你调用matplotlib.pyplot的绘图函数plot()进行绘图的时候,或者生成一个figure画布的时候,可以直接在你的python console里面生成图像。
而我们在spyder或者pycharm实际运行代码的时候,可以直接注释掉这一句,也是可以运行成功的。)
2. https://stackoverflow.com/questions/43027980/purpose-of-matplotlib-inline
    (%matplotlib is a magic function in IPython. I'll quote the relevant documentation here for you to read for convenience:
IPython has a set of predefined ‘magic functions’ that you can call with a command line style syntax. There are two kinds of magics, line-oriented and cell-oriented. Line magics are prefixed with the % character and work much like OS command-line calls: they get as an argument the rest of the line, where arguments are passed without parentheses or quotes. Lines magics can return results and can be used in the right hand side of an assignment. Cell magics are prefixed with a double %%, and they are functions that get as an argument not only the rest of the line, but also the lines below it in a separate argument.)

2. pytorch的语法torch.view

1. https://pytorch.org/docs/stable/tensors.html?highlight=torch%20view#torch.Tensor.view
 Resizing: If you want to resize/reshape tensor, you can use torch.view:
x = torch.randn(4, 4)
y = x.view(16)
z = x.view(-1, 8)  # the size -1 is inferred from other dimensions
print(x.size(), y.size(), z.size())

2. 书中实例
    def squared_loss(y_hat, y): 
    return (y_hat - y.view(y_hat.size())) ** 2 / 2

3. pytorch语法快速入门的途径

1. https://pytorch.org/tutorials/beginner/deep_learning_60min_blitz.html
(差不多两个小时能看完,之后阅读《drive into deep learning》不会很慌了, 但是还是存
    阅读文章时还对其中的语法学习学习有些繁琐)

4. 如何理解
 def linreg(X, w, b):
    return torch.mm(X, w) + b
里的torch.mm

1.https://pytorch.org/docs/stable/torch.html?highlight=torch%20mm#torch.mm
 torch.mm(input, mat2, out=None) → Tensor
Performs a matrix multiplication of the matrices input and mat2.
If input is a (n \times m)(n×m) tensor, mat2 is a (m \times p)(m×p) tensor, out will be a (n \times p)(n×p) tensor.

5. torch非快速查询语法

1.https://pytorch.org/docs/stable/index.html
 这是官网的doc 页面,可以在里面搜索框具体搜索相应的语法, 我总觉得应该在jupyter中应该有个torch语法插件的,实现快速查看语法。

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值