Python torchsummary.summary() Examples

The following are 19 code examples of torchsummary.summary(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module torchsummary , or try the search function .
Example #1
Source File: models.py    From angela with MIT License 6 votes vote down vote up
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,)) 
Example #2
Source File: NIN2013.py    From Pytorch-Networks with MIT License 5 votes vote down vote up
def _test():
    from torchsummary import summary
    model = NIN()
    model = model.cuda()
    summary(model,input_size=(3,224,224)) 
Example #3
Source File: HyperDensenet.py    From MedicalZooPytorch with MIT License 5 votes vote down vote up
def test(self, device='cpu'):
        device = torch.device(device)
        input_tensor = torch.rand(1, 3, 20, 20, 20)
        ideal_out = torch.rand(1, self.num_classes, 20, 20, 20)
        out = self.forward(input_tensor)
        # assert ideal_out.shape == out.shape
        summary(self, (3, 16, 16, 16))
        # torchsummaryX.summary(self, input_tensor.to(device))
        print("HyperDenseNet test is complete!!!", out.shape)

# m = HyperDenseNet(1,4)
# m.test() 
Example #4
Source File: HyperDensenet.py    From MedicalZooPytorch with MIT License 5 votes vote down vote up
def test(self, device='cpu'):
        input_tensor = torch.rand(1, 2, 22, 22, 22)
        ideal_out = torch.rand(1, self.num_classes, 22, 22, 22)
        out = self.forward(input_tensor)
        # assert ideal_out.shape == out.shape
        # summary(self.to(torch.device(device)), (2, 22, 22, 22),device=device)
        # torchsummaryX.summary(self,input_tensor.to(device))
        print("HyperDenseNet test is complete", out.shape) 
Example #5
Source File: models.py    From angela with MIT License 5 votes vote down vote up
def __init__(self, state_size, action_size, seed=0, fc1_units=400, fc2_units=300):
        self.actor_local = LowDimActor(state_size, action_size, seed, fc1_units, fc2_units).to(device)
        self.actor_target = LowDimActor(state_size, action_size, seed, fc1_units, fc2_units).to(device)
        self.critic_local = LowDimCritic(state_size, action_size, seed, fc1_units, fc2_units).to(device)
        self.critic_target = LowDimCritic(state_size, action_size, seed, fc1_units, fc2_units).to(device)
        print(self.actor_local)
        summary(self.actor_local, (state_size,))
        print(self.critic_local)
        #summary(self.critic_local, (state_size, action_size))  # TODO: get this working again 
Example #6
Source File: models.py    From angela with MIT License 5 votes vote down vote up
def __init__(self, state_size, action_size, seed=0, fc1_units=400, fc2_units=300):
        self.actor_local = LowDimActor(state_size, action_size, seed, fc1_units, fc2_units).to(device)
        self.actor_target = LowDimActor(state_size, action_size, seed, fc1_units, fc2_units).to(device)
        self.critic_local = LowDimCritic(state_size, action_size, seed, fc1_units, fc2_units).to(device)
        self.critic_target = LowDimCritic(state_size, action_size, seed, fc1_units, fc2_units).to(device)
        print(self.actor_local)
        summary(self.actor_local, (state_size,))
        print(self.critic_local)
        #summary(self.critic_local, (state_size, action_size))  # TODO: get this working again 
Example #7
Source File: unet.py    From Pytorch_Medical_Segmention_Template with MIT License 5 votes vote down vote up
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)) 
Example #8
Source File: resnet.py    From Pytorch_Medical_Segmention_Template with MIT License 5 votes vote down vote up
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)) 
Example #9
Source File: trial.py    From Text-Recognition with GNU Lesser General Public License v2.1 5 votes vote down vote up
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))) 
Example #10
Source File: MobileNet.py    From Pytorch-Networks with MIT License 5 votes vote down vote up
def _test():
    from torchsummary import summary
    model = MobileNet_V1()
    torch.cuda.set_device(1)
    model = model.cuda()
    summary(model,input_size=(3,224,224)) 
Example #11
Source File: Darknet2016.py    From Pytorch-Networks with MIT License 5 votes vote down vote up
def _test():
    from torchsummary import summary
    model = DarkNet_53()
    torch.cuda.set_device(0)
    model = model.cuda()
    summary(model,input_size=(3,256,256)) 
Example #12
Source File: MnasNet2018.py    From Pytorch-Networks with MIT License 5 votes vote down vote up
def _test():
    from torchsummary import summary
    model = MnasNet_A1()
    model = model.cuda()
    summary(model,input_size=(3,224,224)) 
Example #13
Source File: VGG2014.py    From Pytorch-Networks with MIT License 5 votes vote down vote up
def _test():
    from torchsummary import summary
    model = vgg19()
    model = model.cuda()
    summary(model,input_size=(3,224,224)) 
Example #14
Source File: EfficientNet2019.py    From Pytorch-Networks with MIT License 5 votes vote down vote up
def _test():
    from torchsummary import summary
    model = EfficientNet_B0()
    torch.cuda.set_device(1)
    model = model.cuda()
    summary(model,input_size=(3,224,224)) 
Example #15
Source File: DenseNet2016.py    From Pytorch-Networks with MIT License 5 votes vote down vote up
def _test():
    from torchsummary import summary
    model = DenseNet264()
    model = model.cuda()
    summary(model,input_size=(3,224,224)) 
Example #16
Source File: SEmodule2017.py    From Pytorch-Networks with MIT License 5 votes vote down vote up
def _test():
    from torchsummary import summary
    model = TestNet()
    torch.cuda.set_device(1)
    model = model.cuda()
    summary(model,input_size=(3,224,224)) 
Example #17
Source File: Inception_all.py    From Pytorch-Networks with MIT License 5 votes vote down vote up
def _test():
    from torchsummary import summary
    model = Inception_Res_v2()
    model = model.cuda()
    summary(model,input_size=(3,299,299)) 
Example #18
Source File: ResNeXt2016.py    From Pytorch-Networks with MIT License 5 votes vote down vote up
def _test():
    from torchsummary import summary
    model = ResNeXt50()
    model = model.cuda()
    summary(model,input_size=(3,224,224)) 
Example #19
Source File: ResNetV2.py    From Pytorch-Networks with MIT License 5 votes vote down vote up
def _test():
    from torchsummary import summary
    model = ResNet18()
    model = model.cuda()
    summary(model,input_size=(3,224,224))