In this pytorch ResNet code example they define downsample as variable in line 44. and line 58 use it as function. How this downsample work here as CNN point of view and as python Code point of view. code example : pytorch ResNet i searched for if downsample is any pytorch inbuilt function. but it is not. Answer In this
Tag: deep-learning
What’s the difference between torch.stack() and torch.cat() functions?
OpenAI’s REINFORCE and actor-critic example for reinforcement learning has the following code: REINFORCE: actor-critic: One is using torch.cat, the other uses torch.stack, for similar use cases. As far as my understanding goes, the doc doesn’t give any clear distinction between them. I would be happy to know the differences between the functions. Answer stack Concatenates sequence of tensors along a
Why do we need to call zero_grad() in PyTorch?
Why does zero_grad() need to be called during training? Answer In PyTorch, for every mini-batch during the training phase, we typically want to explicitly set the gradients to zero before starting to do backpropragation (i.e., updating the Weights and biases) because PyTorch accumulates the gradients on subsequent backward passes. This accumulating behaviour is convenient while training RNNs or when we
What is the use of verbose in Keras while validating the model?
I’m running the LSTM model for the first time. Here is my model: What is the use of verbose while training the model? Answer Check documentation for model.fit here. By setting verbose 0, 1 or 2 you just say how do you want to ‘see’ the training progress for each epoch. verbose=0 will show you nothing (silent) verbose=1 will show
Modifying the weights and biases of a restored CNN model in TensorFlow
I have recently started using TensorFlow (TF), and I have come across a problem that I need some help with. Basically, I’ve restored a pre-trained model, and I need to modify the weights and biases of one of its layers before I retest its accuracy. Now, my problem is the following: how can I change the weights and biases using
Getting a list of all known classes of vgg-16 in keras
I use the pre-trained VGG-16 model from Keras. My working source code so far is like this: I wound out that the model is trained on 1000 classes. It there any possibility to get the list of the classes this model is trained on? Printing out all the prediction labels is not an option because there are only 5 returned.
How to reduce the number of training steps in Tensorflow’s Object Detection API?
I am following Dat Trans example to train my own Object Detector with TensorFlow’s Object Detector API. I successfully started to train the custom objects. I am using CPU to train the model but it takes around 3 hour to complete 100 training steps. I suppose i have to change some parameter in .config. I tried to convert .ckpt to
NumPy/PyTorch extract subsets of images
In Numpy, given a stack of large images A of size(N,hl,wl), and coordinates x of size(N) and y of size(N) I want to get smaller images of size (N,16,16) In a for loop it would look like this: But can I do this just with indexing? Bonus question: Will this indexing also work in pytorch? If not how can I
Keras confusion about number of layers
I’m a bit confused about the number of layers that are used in Keras models. The documentation is rather opaque on the matter. According to Jason Brownlee the first layer technically consists of two layers, the input layer, specified by input_dim and a hidden layer. See the first questions on his blog. In all of the Keras documentation the first
Tensorflow on windows – ImportError: DLL load failed: The specified module could not be found
I’m using Anaconda 3.1.0 on Windows 7 64 bit. I have installed tensorflow(GPU). I am getting errors while running following command. >>> import tensorflow as tf The complete traceback Answer cudnn lib version was wrong, so I replaced correct version of cudnn lib and it worked.