<gh_stars>1-10
import matplotlib.pyplot as plt
import numpy as np
from io import BytesIO

import torch
import torch.nn.functional as F
import pandas as pd
from util import getProjectedData

# Define model
class TheModelClass(torch.nn.Module):
    def __init__(self):
        super(TheModelClass, self).__init__()
        self.conv1 = torch.nn.Conv2d(3, 6, 5)
        self.pool  = torch.nn.MaxPool2d(2, 2)
        self.conv2 = torch.nn.Conv2d(6, 16, 5)
        self.fc1   = torch.nn.Linear(16 * 5 * 5, 120)
        self.fc2   = torch.nn.Linear(120, 84)
        self.fc3   = torch.nn.Linear(84, 10)

    def forward(self, x):
        x = self.pool(F.relu(self.conv1(x)))
        x = self.pool(F.relu(self.conv2(x)))
        x = x.view(-1, 16 * 5 * 5)
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = self.fc3(x)
        return x

# Initialize model
model = TheModelClass()

# Initialize optimizer
optimizer = torch.optim.SGD(model.parameters(), lr=0.001, momentum=0.9)

# Print model's state_dict
print("Model's state_dict:")
for param_tensor in model.state_dict():
    print(param_tensor, "\t", model.state_dict()[param_tensor].size())

# # Print optimizer's state_dict
# print("Optimizer's state_dict:")
# for var_name in optimizer.state_dict():
#     print(var_name, "\t", optimizer.state_dict()[var_name])


# torch.save(model.state_dict(), "./TheModelClass_state_dict.pt")


# model2 = TheModelClass()
# model2.load_state_dict(torch.load("./TheModelClass_state_dict.pt"))
# model2.eval()


# # Print model's state_dict
# print("Model's state_dict:")
# for param_tensor in model2.state_dict():
#     print(param_tensor, "\t", model2.state_dict()[param_tensor].size())

import matplotlib.pyplot as plt
import numpy as np
from io import BytesIO

import torch
import torch.nn.functional as F
import pandas as pd
from util import getProjectedData

# Define model
class TheModelClass(torch.nn.Module):
    def __init__(self):
        super(TheModelClass, self).__init__()
        self.conv1 = torch.nn.Conv2d(3, 6, 5)
        self.pool  = torch.nn.MaxPool2d(2, 2)
        self.conv2 = torch.nn.Conv2d(6, 16, 5)
        self.fc1   = torch.nn.Linear(16 * 5 * 5, 120)
        self.fc2   = torch.nn.Linear(120, 84)
        self.fc3   = torch.nn.Linear(84, 10)

    def forward(self, x):
        x = self.pool(F.relu(self.conv1(x)))
        x = self.pool(F.relu(self.conv2(x)))
        x = x.view(-1, 16 * 5 * 5)
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = self.fc3(x)
        return x

# Initialize model
model = TheModelClass()

# Initialize optimizer
optimizer = torch.optim.SGD(model.parameters(), lr=0.001, momentum=0.9)

# Print model's state_dict
print("Model's state_dict:")
for param_tensor in model.state_dict():
    print(param_tensor, "\t", model.state_dict()[param_tensor].size())

# # Print optimizer's state_dict
# print("Optimizer's state_dict:")
# for var_name in optimizer.state_dict():
#     print(var_name, "\t", optimizer.state_dict()[var_name])


# torch.save(model.state_dict(), "./TheModelClass_state_dict.pt")


# model2 = TheModelClass()
# model2.load_state_dict(torch.load("./TheModelClass_state_dict.pt"))
# model2.eval()


# # Print model's state_dict
# print("Model's state_dict:")
# for param_tensor in model2.state_dict():
#     print(param_tensor, "\t", model2.state_dict()[param_tensor].size())
# Define model # Initialize model # Initialize optimizer # Print model's state_dict # # Print optimizer's state_dict # print("Optimizer's state_dict:") # for var_name in optimizer.state_dict(): #     print(var_name, "\t", optimizer.state_dict()[var_name]) # torch.save(model.state_dict(), "./TheModelClass_state_dict.pt") # model2 = TheModelClass() # model2.load_state_dict(torch.load("./TheModelClass_state_dict.pt")) # model2.eval() # # Print model's state_dict # print("Model's state_dict:") # for param_tensor in model2.state_dict(): #     print(param_tensor, "\t", model2.state_dict()[param_tensor].size())