美文网首页
大白话说pytorch入门系列教程一:Tensor

大白话说pytorch入门系列教程一:Tensor

作者: 真行僧_47d5 | 来源:发表于2020-02-02 22:27 被阅读0次

    [{"metadata":{"pycharm":{"is_executing":false,"name":"#%%matplotlib inline\n"},"trusted":false},"cell_type":"raw","source":"import torch\nimport numpy\n\n#输入shape 创建一个随机的tensor,标准正态分布\na=torch.randn(2,2)\nprint(a)\n\n"},{"metadata":{"pycharm":{"is_executing":false,"name":"#%%\n"},"trusted":false},"cell_type":"markdown","source":"import torch\nimport numpy\n#输入shape 创建一个随机的tensor 随机值在【0,1】之间 均匀分布\na=torch.rand(2,2)\nprint(a)"},{"metadata":{"pycharm":{"is_executing":false,"name":"#%%\n"},"trusted":false},"cell_type":"code","source":"import torch\nimport numpy\na=torch.rand(2,2)\n#根据一个tensor的形状 随机创建另一个tensor\nb=torch.rand_like(a)\nprint(b)","execution_count":23,"outputs":[{"name":"stdout","text":"tensor([[0.0480, 0.4929],\n [0.2032, 0.9467]])\n","output_type":"stream"}]}]

    相关文章

      网友评论

          本文标题:大白话说pytorch入门系列教程一:Tensor

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