pytorch

train pytorch CNN to specific image style

train pytorch CNN to specific image style Question: I’m trying to train pytorch CNN model to transform my images into specific style. I found tutorial for this at https://pytorch.org/tutorials/advanced/neural_style_tutorial.html, but this will transform the image in multiple iterations and I need to have a model that do the same thing to use it in C++ …

Total answers: 1

self() as function within class, what does it do?

self() as function within class, what does it do? Question: Sorry for the poor title but I’m unsure how better to describe the question. So I recently watched Andrej Kaparthy’s build GPT video which is awesome and now trying to reconstruct the code myself I notices that he uses self() as a function and was …

Total answers: 1

How to improve pytroch model?

How to improve pytroch model? Question: Good evening, I have 4 classes with black and white images each class has 3000 images with a test of 600 images so how to improve this model and that’s my full code: data_transform = transforms.Compose([ transforms.Grayscale(num_output_channels=1), transforms.Resize(size=(150, 150)), transforms.ToTensor(), transforms.Normalize(mean=[0.5], std=[0.5]), ]) Loading Images using ImageFolder train_data = …

Total answers: 2

Pytorch deeplearning

Pytorch deeplearning Question: I am trying to train a model with the data of the size: torch.Size([280652, 87]) and the target: torch.Size([280652, 64]) with 80% in the training data and 20 in the test data. My code: #split the data in train and test X_train, X_test, y_train, y_test = train_test_split(data, target, test_size=0.2) # convert to …

Total answers: 1

Pytorch: Receiving same test evaluations each round

Pytorch: Receiving same test evaluations each round Question: I have a problem with my federated learning setup. I have some weights which I want to evaluate (test) each round using PyTorch. For now im interested in the loss and accuracy of the model. The weights are a list of numpy arrays. The model im using …

Total answers: 1

Torch in python unable to get some layers like add from model structure

Torch in python unable to get some layers like add from model structure Question: I have this simple code to write down structure of network. model = torch.jit.load(‘best5.torchscript’) file_object = open(‘sample.txt’, ‘a’) for name, module in model.named_modules(): file_object.write(str(module)) Problem is that some layers like "add" is not present for example this is part from output …

Total answers: 1

Get all layers including operators from torch in python

Get all layers including operators from torch in python Question: I want to get all layers like convolution etc… and operator like "add" in python but I really dont know how. This is my code import torch # An instance of your model. model = torch.jit.load(‘best5.torchscript’) # Print all the layers for name, param in …

Total answers: 1

How to make formula differentiable for a binary classifier in PyTorch

How to make formula differentiable for a binary classifier in PyTorch Question: I am trying to create a custom loss function for a binary classifier case. I need the binary predictions as an input to the function. However, I am getting to a point where I am unable to create a the process differentiable. I …

Total answers: 1

Sort a vector in PyTorch

Sort a vector in PyTorch Question: I am performing a prediction using an input image and a pre-trained classifier on ImageNet using PyTorch. What I would like to do is to calculate the value for each for the class and returned the highest 10 values. My code looks like: img = imread_img(‘image.png’) input = pre_processing(img) …

Total answers: 2

Converting column of object type to pytorch tensor

Converting column of object type to pytorch tensor Question: I am new to machine learning and python. I am working on data which has 2 columns of object type and a large number of columns of float type. For converting a float type columns to tensor, the below code works fine: cont_cols = [‘row_id’, ‘player1′,’player2′,’playervar_0′,’player_1’] …

Total answers: 2