<jupyter_start><jupyter_text>Mean and Standard Deviation for Cifar Dataset -Mean: tensor([0.4914, 0.4822, 0.4465])Standard deviation: tensor([0.2471, 0.2435, 0.2616])<jupyter_code>data_transforms = {
    'train': transforms.Compose([
        transforms.RandomHorizontalFlip(),
        #transforms.RandomRotation(degrees=(90)),
        transforms.RandomCrop(32, padding=4),
        #transforms.ColorJitter(brightness=0.5, contrast=0.5, saturation=0.5, hue=0.5),
        transforms.ToTensor(),
        transforms.Normalize([0.4914, 0.4822, 0.4465], [0.2471, 0.2435, 0.2616]),
#         transforms.RandomErasing(),

    ]),
    'val': transforms.Compose([
        # transforms.CenterCrop(224),
        transforms.ToTensor(),
        transforms.Normalize([0.4914, 0.4822, 0.4465], [0.2471, 0.2435, 0.2616])
    ]),
}


dataloaders = {}
for phase in ['train','val']:
    dataset = datasets.CIFAR10(root='./data', train=(phase=='train'),download=True, transform=data_transforms[phase])
    dataloaders[phase] = torch.utils.data.DataLoader(dataset, batch_size=batch_size,shuffle=(phase=='train'), num_workers=num_workers)
model = ResNet(BasicBlock, channels, num_res_layer, res_blocks,kernel=kernel,skip_kernel=skip_kernel)
model = model.to(device)
LossFunc = torch.nn.CrossEntropyLoss()

optimizer = torch.optim.Adadelta(model.parameters(), lr=learningRate, weight_decay=weight_decay)

save_loss = {'train':[], 'val':[]}
save_acc = {'train':[], 'val':[]}
from torchsummary import summary
print(summary(model, input_size=(3, 32, 32)))
for epoch in tqdm(range(200)):
    # Each epoch has a training and validation phase
    for phase in ['train', 'val']:
        if phase == 'train':
            model.train()  # Set model to training mode
        else:
            model.eval()   # Set model to evaluate mode

        current_loss = 0.0
        current_corrects = 0

        for batch_idx, (inputs, labels) in enumerate(dataloaders[phase], 1):
            inputs,labels = inputs.to(device), labels.to(device)
            optimizer.zero_grad()

            # Time to carry out the forward training poss
            with torch.set_grad_enabled(phase == 'train'):
                outputs = model(inputs)
                _, preds = torch.max(outputs, 1)
                loss = LossFunc(outputs, labels)

                # backward + optimize only if in training phase
                if phase == 'train':
                    loss.backward()
                    optimizer.step()

            # We want variables to hold the loss/acc statistics
            current_loss += loss.item() * inputs.size(0)
            current_corrects += torch.sum(preds == labels.data)
        # saving variable for plottin
        save_loss[phase] += [current_loss / len(dataloaders[phase].dataset)]
        save_acc[phase] += [current_corrects.float() / len(dataloaders[phase].dataset)]
        print(f"Epoch:{epoch} -- Phase:{phase} -- Loss:{save_loss[phase][-1]:.2f} -- Acc:{save_acc[phase][-1]*100:.2f}")

plt.plot(save_acc['train'])
plt.plot(save_acc['val'])
plt.legend(["train", "val"])
plt.title("Accuracy")

print(max(save_acc['val']),min(save_loss['val']))
plt.plot(save_loss['train'])
plt.plot(save_loss['val'])
plt.legend(["train", "val"])
plt.title("Loss")
# save resnet model
PATH = './project1_model.pt'
torch.save(model.state_dict(), PATH)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15602625298329356, 'fraction_numerical': 0.038782816229116945, 'mean_word_length': 3.3376455368693403, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '365247', 'license': 'MIT', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1077, 'n_words': 208, 'path': 'resnet-nb.ipynb', 'repo_name': 'akashsky1994/ResNet-Design', 'size': '3352'}