pytorch

PyTorch Cuda with anaconda not available

安稳与你 提交于 2021-01-29 10:37:00
问题 I'm using anaconda to regulate my environment, for a project i have to use my GPU for network training. I use pytorch for my project and i'm trying to get CUDA working. I installed cudatoolkit, numba, cudnn still, when i try this command: torch.cuda.is_available() I get "False" as output. This is my environment: # Name Version Build Channel blas 1.0 mkl bzip2 1.0.6 h470a237_2 conda-forge ca-certificates 2018.03.07 0 cairo 1.14.12 he6fea26_5 conda-forge certifi 2018.8.24 py35_1 cffi 1.11.5

Why pytorch training on CUDA works much slower than in CPU?

我与影子孤独终老i 提交于 2021-01-29 09:49:03
问题 I guess i have made something in folowing simple neural network with PyTorch, because this runs much slower with CUDA then in CPU, can you find the mistake pls. The using function like def backward(ctx, input): return backward_sigm(ctx, input) seems have no real impact on preformance import torch import torch.nn as nn import torch.nn.functional as f dname = 'cuda:0' dname = 'cpu' device = torch.device(dname) print(torch.version.cuda) def forward_sigm(ctx, input): sigm = 1 / (1 + torch.exp(

Loading data from Custom Data-Loader in pytorch only if the data specifies a certain condition

南笙酒味 提交于 2021-01-29 09:32:14
问题 I have a CSV file with filename in the first column and a label for the filename in the second column. I also have a third column, which specifies something about the data (whether the data meets a specific condition). It will look something like, +-----------------------------+ | Filepath 1 Label 1 'n' | | | +-----------------------------+ | Filepath 2 Label 2 'n' | | | | | +-----------------------------+ | Filepath 3 Label 3 'n'| | | +-----------------------------+ | Filepath 4 Label 4 'y'|

torch.optim returns “ValueError: can't optimize a non-leaf Tensor” for multidimensional tensor

梦想的初衷 提交于 2021-01-29 08:42:16
问题 I am trying to optimize the translations of the vertices of a scene with torch.optim.adam . It is a code piece from the redner tutorial series, which works fine with the initial setting. It tries to optimize a scene with shifting all the vertices by the same value called translation . Here is the original code: vertices = [] for obj in base: vertices.append(obj.vertices.clone()) def model(translation): for obj, v in zip(base, vertices): obj.vertices = v + translation # Assemble the 3D scene.

Can't init the weights of my neural network PyTorch

牧云@^-^@ 提交于 2021-01-29 08:27:29
问题 I can't initialize the weights with the function MyNet.apply(init_weights). These are my functions: def init_weights(net): if type(net) == torch.nn.Module: torch.nn.init.kaiming_uniform_(net.weight) net.bias.data.fill_(0.01) # tots els bias a 0.01 My neural net is the following: class NeuralNet(torch.nn.Module): def __init__(self): super().__init__() # Necessary for torch to detect this class as trainable # Here define network architecture self.layer1 = torch.nn.Linear(28**2, 32).to(device) #

Why does one Python script raise a qt.qpa.plugin error, while another identical script does not?

痴心易碎 提交于 2021-01-29 08:10:20
问题 I have two virtually identical scripts running in the same PyCharm IDE. They both call into a third script that uses matplotlib to output a Numpy array to a PNG. One of the scripts works fine and outputs the PNG. The other script raises the following error: qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "" even though it was found. The differences between the scripts are minimal - they only vary in that they each import a different pytorch model (both models created by me).

IndexError: index out of range in self

为君一笑 提交于 2021-01-29 07:40:29
问题 i got this error in runtime, can you please help me? my vocab size is 76, as shown in below, Some of my codes are below: class LSTMClassifier(nn.Module): def __init__(self, embed_size, hidden_size, vocab_size, num_layers, num_classes, batch_size): super(LSTMClassifier, self).__init__() self.embed_size = embed_size self.hidden_size = hidden_size self.batch_size = batch_size self.num_layers = num_layers self.embedding = nn.Embedding(vocab_size, embed_size) # a lookup table self.lstm = nn.LSTM

Normalizing images passed to torch.transforms.Compose function

老子叫甜甜 提交于 2021-01-29 07:21:53
问题 How to find the values to pass to the transforms.Normalize function in PyTorch? Also, where in my code, should I exactly do the transforms.Normalize? Since normalizing the dataset is a pretty well-known task, I was hoping there should be some sort of script for doing that automatically. At least I couldn't find it in PyTorch forum. transformed_dataset = MothLandmarksDataset(csv_file='moth_gt.csv', root_dir='.', transform=transforms.Compose([ Rescale(256), RandomCrop(224), transforms.Normalize

How To Get The Pixel Count Of A Segmented Area in an Image I used Vgg16 for Segmentation

人盡茶涼 提交于 2021-01-29 06:44:59
问题 I am new to deep learning but have succeeded in semantic segmentation of the image I am trying to get the pixel count of each class in the label. As an example in the image I want to get the pixel count of the carpet, or the chandelier or the light stand. How do I go about? Thanks any suggestions will help. 回答1: Edit: In what format the regions are returned? Do you have only the final image or the regions are given as contours? If you have them as contours (list of coordinates), you can apply

How to compensate if I cant do a large batch size in neural network

大城市里の小女人 提交于 2021-01-29 05:34:44
问题 I am trying to run an action recognition code from GitHub. The original code used a batch size of 128 with 4 GPUS. I only have two gpus so I cannot match their bacth size number. Is there anyway I can compensate this difference in batch. I saw somewhere that iter_size might compensate according to a formula effective_batchsize= batch_size*iter_size*n_gpu . what is iter_size in this formula? I am using PYthorch not Caffe. 回答1: In pytorch, when you perform the backward step (calling loss