美文网首页
Python学习笔记(3)

Python学习笔记(3)

作者: Yankee_13 | 来源:发表于2018-11-16 13:28 被阅读0次

一、对于矩阵:

~x=tensor([[0, 1, 2, 3, 4],

                [5, 6, 7, 8, 9]], dtype=torch.int32)

~print(x[:,1])

输出结果为[1,6],应该比较好理解吧

二、避免浅拷贝的方法:

    matrix= [[1 for i in range(n)]for i in range(m)]

    这样来初始化矩阵可以避免浅拷贝

    https://blog.csdn.net/edogawachia/article/details/79762310

    http://www.runoob.com/w3cnote/python-understanding-dict-copy-shallow-or-deep.html

三、控制GPU使用

    os.environ["CUDA_VISIBLE_DEVICES"] ="0"

    指定使用GPU"0"

四、字典get函数

    dict.get(key, default=None)

    Python 字典(Dictionary) get() 函数返回指定键的值,如果值不在字典中返回默认值。

相关文章

网友评论

      本文标题:Python学习笔记(3)

      本文链接:https://www.haomeiwen.com/subject/krcmfqtx.html