backpropagation

What does the parameter retain_graph mean in the Variable's backward() method?

不羁的心 提交于 2019-11-27 10:33:45
问题 I'm going through the neural transfer pytorch tutorial and am confused about the use of retain_variable (deprecated, now referred to as retain_graph ). The code example show: class ContentLoss(nn.Module): def __init__(self, target, weight): super(ContentLoss, self).__init__() self.target = target.detach() * weight self.weight = weight self.criterion = nn.MSELoss() def forward(self, input): self.loss = self.criterion(input * self.weight, self.target) self.output = input return self.output def

How to use k-fold cross validation in a neural network

别等时光非礼了梦想. 提交于 2019-11-27 09:18:23
问题 We are writing a small ANN which is supposed to categorize 7000 products into 7 classes based on 10 input variables. In order to do this we have to use k-fold cross validation but we are kind of confused. We have this excerpt from the presentation slide: What are exactly the validation and test sets? From what we understand is that we run through the 3 training sets and adjust the weights (single epoch). Then what do we do with the validation? Because from what I understand is that the test

numpy : calculate the derivative of the softmax function

拜拜、爱过 提交于 2019-11-27 01:29:40
问题 I am trying to understand backpropagation in a simple 3 layered neural network with MNIST . There is the input layer with weights and a bias . The labels are MNIST so it's a 10 class vector. The second layer is a linear tranform . The third layer is the softmax activation to get the output as probabilities. Backpropagation calculates the derivative at each step and call this the gradient. Previous layers appends the global or previous gradient to the local gradient . I am having trouble

Difference on performance between numpy and matlab

假如想象 提交于 2019-11-27 00:23:08
问题 I am computing the backpropagation algorithm for a sparse autoencoder. I have implemented it in python using numpy and in matlab . The code is almost the same, but the performance is very different. The time matlab takes to complete the task is 0.252454 seconds while numpy 0.973672151566, that is almost four times more. I will call this code several times later in a minimization problem so this difference leads to several minutes of delay between the implementations. Is this a normal

Why is the Cross Entropy method preferred over Mean Squared Error? In what cases does this doesn't hold up? [closed]

梦想与她 提交于 2019-11-26 22:37:30
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . Although both of the above methods provide better score for better closeness of prediction, still cross-entropy is preferred. Is it in every cases or there are some peculiar scenarios where we prefer cross-entropy over MSE? 回答1: Cross-entropy is prefered for classification , while