Python
野草.
这个作者很懒,什么都没留下…
展开
-
PyTorch中scatter()和scatter_()函数的作用
本文讲的是我对PyTorch中scatter()函数的理解。 原创,转载请标明来源。 一言以蔽之:修改tensor中的指定位置的值。 函数 scatter(dim, index, src) dim: 索引的维度。按照i, j, k, ...的哪个方向进行索引 index: 索引。可以是一个tensor,存储需要改的元素的位置的tensor src: 用src中的值来修改。可以是tensor;可以是一个数字,用同样的数字写入tensor scatter() 和 scatter_() 函数..原创 2020-10-04 15:20:44 · 1494 阅读 · 0 评论 -
Python | **,**kwargs,*,*args的作用
(Python版本3.7.4) 1. **与**kwargs 1.1 **的作用 **的作用是将字典中的内容作为参数传入函数中。 # 举例 def print1(a, b, c): print(a, b, c) # 定义一个字典 dict = {'a':1, 'b':2, 'c':3} # 传入函数中 print1(**dict) 函数返回: 1 2 3 在print1(...原创 2020-04-08 10:43:09 · 142 阅读 · 0 评论