本文整理汇总了Python中torchsummary.summary方法的典型用法代码示例。如果您正苦于以下问题:Python torchsummary.summary方法的具体用法?Python torchsummary.summary怎么用?Python torchsummary.summary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torchsummary
的用法示例。
在下文中一共展示了torchsummary.summary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def __init__(self, n_agents, state_size=24, action_size=2, seed=0):
"""
Params
======
n_agents (int): number of distinct agents
state_size (int): number of state dimensions for a single agent
action_size (int): number of action dimensions for a single agent
seed (int): random seed
"""
self.actor_local = LowDimActor(state_size, action_size, seed).to(device)
self.actor_target = LowDimActor(state_size, action_size, seed).to(device)
critic_input_size = (state_size+action_size)*n_agents
self.critic_local = LowDimCritic(critic_input_size, seed).to(device)
self.critic_target = LowDimCritic(critic_input_size, seed).to(device)
# output model architecture
print(self.actor_local)
summary(self.actor_local, (state_size,))
print(self.critic_local)
#summary(self.critic_local, (state_size*n_agents,), (action_size*n_agents,))
示例2: resnet152
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def resnet152(pretrained=False, **kwargs):
"""Constructs a ResNet-152 model.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
model = ResNet(Bottleneck, [3, 8, 36, 3], **kwargs)
if pretrained:
model.load_state_dict(model_zoo.load_url(model_urls['resnet152']))
return model
# net = resnet34(pretrained=False)
# torchsummary.summary(net, (3, 512, 512))
示例3: _test
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def _test():
from torchsummary import summary
model = DarkNet_53()
torch.cuda.set_device(0)
model = model.cuda()
summary(model,input_size=(3,256,256))
示例4: _test
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def _test():
from torchsummary import summary
model = ResNet18()
model = model.cuda()
summary(model,input_size=(3,224,224))
示例5: _test
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def _test():
from torchsummary import summary
model = ResNeXt50()
model = model.cuda()
summary(model,input_size=(3,224,224))
示例6: _test
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def _test():
from torchsummary import summary
model = Inception_Res_v2()
model = model.cuda()
summary(model,input_size=(3,299,299))
示例7: _test
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def _test():
from torchsummary import summary
model = TestNet()
torch.cuda.set_device(1)
model = model.cuda()
summary(model,input_size=(3,224,224))
示例8: _test
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def _test():
from torchsummary import summary
model = DenseNet264()
model = model.cuda()
summary(model,input_size=(3,224,224))
示例9: _test
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def _test():
from torchsummary import summary
model = EfficientNet_B0()
torch.cuda.set_device(1)
model = model.cuda()
summary(model,input_size=(3,224,224))
示例10: _test
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def _test():
from torchsummary import summary
model = vgg19()
model = model.cuda()
summary(model,input_size=(3,224,224))
示例11: _test
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def _test():
from torchsummary import summary
model = MnasNet_A1()
model = model.cuda()
summary(model,input_size=(3,224,224))
示例12: _test
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def _test():
from torchsummary import summary
model = NIN()
model = model.cuda()
summary(model,input_size=(3,224,224))
示例13: _test
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def _test():
from torchsummary import summary
model = MobileNet_V1()
torch.cuda.set_device(1)
model = model.cuda()
summary(model,input_size=(3,224,224))
示例14: own
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def own():
nc=3
rnn_hidden_size=256
rnn_num_layers=2
leakyRelu=False
ks = [3, 3, 3, 3, 3, 3, 2]
ps = [1, 1, 1, 1, 1, 1, 0]
ss = [1, 1, 1, 1, 1, 1, 1]
nm = [64, 128, 256, 256, 512, 512, 512]
cnn = nn.Sequential()
def convRelu(i, batchNormalization=False):
nIn = nc if i == 0 else nm[i - 1]
nOut = nm[i]
cnn.add_module('conv{0}'.format(i),
nn.Conv2d(nIn, nOut, ks[i], ss[i], ps[i]))
if batchNormalization:
cnn.add_module('batchnorm{0}'.format(i), nn.BatchNorm2d(nOut))
if leakyRelu:
cnn.add_module('relu{0}'.format(i),
nn.LeakyReLU(0.2, inplace=True))
else:
cnn.add_module('relu{0}'.format(i), nn.ReLU(True))
convRelu(0)
cnn.add_module('pooling{0}'.format(0), nn.MaxPool2d(2, 2)) # 64x16x64
convRelu(1)
cnn.add_module('pooling{0}'.format(1), nn.MaxPool2d(2, 2)) # 128x8x32
convRelu(2, True)
convRelu(3)
cnn.add_module('pooling{0}'.format(2),
nn.MaxPool2d((2, 2), (2, 1), (0, 1))) # 256x4x16
convRelu(4, True)
convRelu(5)
cnn.add_module('pooling{0}'.format(3),
nn.MaxPool2d((2, 2), (2, 1), (0, 1))) # 512x2x16
convRelu(6, True) # 512x1x16
print(summary(cnn.cuda(), (3,32,150)))
示例15: weights_init_kaiming
# 需要导入模块: import torchsummary [as 别名]
# 或者: from torchsummary import summary [as 别名]
def weights_init_kaiming(m):
classname = m.__class__.__name__
#print(classname)
if classname.find('Conv') != -1:
init.kaiming_normal_(m.weight.data, a=0, mode='fan_in')
elif classname.find('Linear') != -1:
init.kaiming_normal_(m.weight.data, a=0, mode='fan_in')
elif classname.find('BatchNorm') != -1:
init.normal_(m.weight.data, 1.0, 0.02)
init.constant_(m.bias.data, 0.0)
#model = UNet()
#torchsummary.summary(model, (1, 512, 512))