#StackBounty: #python #tensorflow #pytorch #model-selection #transfer-learning Transfer Learning Question: Extending the Functionality …

Bounty: 100

I have experimented with a number of different machine learning models used for pose estimation. Most of them output a heatmap and offsets for the detected person(s) in the image. I really like the performance/accuracy of the multipose estimation model here.

What I would like to do next is to create a model similar to this one, except it should label each pose of the person(s) detected. There are multiple different implementations caffe/pytorch/tensorflow to choose from. I’ve thought about how to approach this and I have thought of a few different ways:

  1. Create a completely new machine learning model and use the labeled output of the pose estimation model to train it.
  2. Change or add layers to the machine learning model to change the output. (Not sure how this is done)
  3. Ditch the pose estimate model and train a new model to directly estimate using raw images/labels of cropped people. This would rely on another method to detect each person.

I want to take the path of least resistance here but I also care about the time it takes to gather/process data, and most importantly the accuracy/performance of the model. Are there any experienced Machine Learning/Data Scientists who answer the following?

  • Which approach should I take? advantages/disadvantages
  • Which machine learning library offers the functions to do this.
  • My assumption is that option 1 or 2 would be more accurate than option 3. Am I correct?


Get this bounty!!!

#StackBounty: #pytorch #autograd Activation gradient penalty

Bounty: 50

Here’s a simple neural network, where I’m trying to penalize the norm of activation gradients:

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(3, 32, kernel_size=5)
        self.conv2 = nn.Conv2d(32, 64, kernel_size=5)
        self.pool = nn.MaxPool2d(2, 2)
        self.relu = nn.ReLU()
        self.linear = nn.Linear(64 * 5 * 5, 10)

    def forward(self, input):
        conv1 = self.conv1(input)
        pool1 = self.pool(conv1)
        self.relu1 = self.relu(pool1)
        self.relu1.retain_grad()
        conv2 = self.conv2(relu1)
        pool2 = self.pool(conv2)
        relu2 = self.relu(pool2)
        self.relu2 = relu2.view(relu2.size(0), -1)
        self.relu2.retain_grad()
        return self.linear(relu2)

model = Net()
optimizer = torch.optim.SGD(model.parameters(), lr=0.001)

for i in range(1000):
    output = model(input)
    loss = nn.CrossEntropyLoss()(output, label)
    optimizer.zero_grad()
    loss.backward(retain_graph=True)

    grads = torch.autograd.grad(loss, [model.relu1, model.relu2], create_graph=True)

    grad_norm = 0
    for grad in grads:
        grad_norm += grad.pow(2).sum()

    grad_norm.backward()

    optimizer.step()

However, it does not produce the desired regularization effect. If I do the same thing for weights (instead of activations), it works well. Am I doing this right (in terms of pytorch machinery)? Specifically, what happens in grad_norm.backward() call? I just want to make sure the weight gradients are updated, and not activation gradients. Currently, when I print out gradients for weights and activations immediately before and after that line, both change – so I’m not sure what’s going on.


Get this bounty!!!

#StackBounty: #python #autocomplete #sublimetext3 #pytorch #code-completion PyTorch autocomplete in Sublime Text 3

Bounty: 50

I’m a fan of Sublime Text 3 and would like to get code autocompletion for PyTorch. However, I can’t get this working yet. Any suggestions or starting points where I can begin to get this working?

I have searched in the packages repository of Sublime Text but unfortunately there’s none.

Note: I have looked at a related question here IDE autocomplete for pytorch but that’s only for VS Code.


Get this bounty!!!