• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
村雨sup
自己选的路,跪着也要走完 XD
博客园    首页    新随笔    联系   管理    订阅  订阅
Pytorch 一些函数用法

PyTorch中view的用法:https://blog.csdn.net/york1996/article/details/81949843

max用法

import torch

d=torch.Tensor([[1,3],[2,4]])
print(d)

tensor([[1., 3.],
        [2., 4.]])

import torch

d=torch.Tensor([[1,3],[2,4]])
print(torch.max(d,0))
print(torch.max(d,1))

(tensor([2., 4.]), tensor([1, 1]))
(tensor([3., 4.]), tensor([1, 1]))

torch.max()返回两个结果,第一个是最大值,第二个是对应的索引值;第二个参数 0 代表按列取最大值并返回对应的行索引值,1 代表按行取最大值并返回对应的列索引值。

posted on 2018-08-29 10:04  村雨sup  阅读(1258)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3