文章分类 - pytorch
摘要:1 单GPU pytorch使用GPU,需要把数据和模型从内存转移到GPU 对于张量,一律使用方法 .to(device) 或者 .cuda()即可。 pytorch.Tensor(shapes).to(device)或者 torch.Tensor(shapes).cuda() 对于模型,也是使用同
阅读全文
posted @ 2021-08-30 19:59
大大的海棠湾
摘要:torch定义了7种cpu tensor类型和8中gpu tensor类型 使用时,直接传入数字,就是按照形状初始化 torch.FloatTensor(2,3) torch.DoubleTensor(2,3) torch.ByteTensor(2,3) torch.CharTensor(2,3)
阅读全文
posted @ 2021-08-26 11:46
大大的海棠湾
摘要:nn.Conv2是一个类,而F.conv2d是一个函数 这两个功能并无区别,这两种实现方式同时存在的原因如下 在建图过程中,往往有两种层,一种如全连接层 当中是有Variable ,另外一种是如Pooling Relu层,当中是没有Variable 如果所有的层都用nn.funcitonal来定义,
阅读全文
posted @ 2020-10-22 22:17
大大的海棠湾