1 Star 0 Fork 2

AIRobot/ResnetGPT_DeepReinforcementLearning

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
resnet_utils.py 684 Bytes
一键复制 编辑 原始数据 按行查看 历史
fengquanli 提交于 2021-01-06 05:08 . original
import torch
import torch.nn as nn
import torch.nn.functional as F
class myResnet(nn.Module):
def __init__(self, resnet):
super(myResnet, self).__init__()
self.resnet = resnet
def forward(self, img, att_size=6):
x = img
x = self.resnet.conv1(x)
x = self.resnet.bn1(x)
x = self.resnet.relu(x)
x = self.resnet.maxpool(x)
x = self.resnet.layer1(x)
x = self.resnet.layer2(x)
x = self.resnet.layer3(x)
x = self.resnet.layer4(x)
fc = x.mean(3).mean(2).squeeze()
att = F.adaptive_avg_pool2d(x,[att_size,att_size]).squeeze().permute(1, 2, 0)
return fc, att
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/MagicUniverse/ResnetGPT_DeepReinforcementLearning.git
git@gitee.com:MagicUniverse/ResnetGPT_DeepReinforcementLearning.git
MagicUniverse
ResnetGPT_DeepReinforcementLearning
ResnetGPT_DeepReinforcementLearning
master

搜索帮助