[{"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"}]}]
网友评论