Skip to content

Comments

Austin doolittle#3

Open
glcanvas wants to merge 50 commits intomasterfrom
AustinDoolittle
Open

Austin doolittle#3
glcanvas wants to merge 50 commits intomasterfrom
AustinDoolittle

Conversation

@glcanvas
Copy link
Owner

No description provided.

main_gain.py Outdated
gain = gain.AttentionGAIN("all-segments-exists", 5, gpu=False)

loader = il.DatasetLoader.initial()
train = loader.load_tensors(0, 13, 2000)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signature is load_tensors(self, lower_bound=None, upper_bound=None, load_first_segments: int = 10 ** 20)
I guess it was intended to be train = loader.load_tensors(0, 2000, 13) ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

described at wednesday

image_loader.py Outdated
labels = []
# trusted = None
for idx, i in enumerate(P.labels_attributes):
segments.append(dct[i].tolist())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using tensor concatenation (torch.cat) would be more readable than converting to list and then back to tensor

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

batch_size = labels.shape[0]
output_cl = self.model(images)

grad_target = output_cl * class_label
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why to compute the gradient during model evaluation?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

described, resolved

Copy link
Owner Author

@glcanvas glcanvas Dec 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this is redudant because in lines bellow:

loss_cl = self.loss_classifier(output_cl, class_label)
loss_cl.backward()
optimizer.step()``` 
we do the same

classifier.py Outdated
output_cl = self.model(images)

grad_target = output_cl * class_label
grad_target.backward(gradient=class_label * output_cl, retain_graph=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the gradient of grad_target used? it certainly affects gradients during training. But what's the point of this operation?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

gain.py Outdated
return tensor.data.cpu().item()


def reduce_boundaries(boundaries: int, batch_size=10):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could make this method 1000 times faster with such implementation:
HUGE = -10000
zeros = torch.zeros((batch_size, 1, 224, 224))
zeros[:,:,0:boundaries,:] = HUGE
zeros[:,:,224-boundaries:224,:] = HUGE
zeros[:,:,:,0:boundaries] = HUGE
zeros[:,:,:,224-boundaries:224] = HUGE
return zeros

gain.py Outdated
# weights_new_shape = (1, weights.shape[0] * weights.shape[1], weights.shape[2], weights.shape[3])
# weights = weights.view(weights_new_shape).unsqueeze(0)

self._last_grad = self._last_grad # weights
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was intended to be there?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed here, but Pycharm marked it with yellow color what is annoyed

gain.py Outdated
grad_target = output_cl * label
grad_target[:, ill_index * 2].backward(gradient=label[:, ill_index * 2] * output_cl[:, ill_index * 2],
retain_graph=True)
grad_target[:, ill_index * 2 + 1].backward(gradient=label[:, ill_index * 2] * output_cl[:, ill_index * 2],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it certain that the backward argument should be ill_index2 and not ill_index2+1?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

image_loader.py Outdated
transforms.ToTensor(),
])

"""normalization = transforms.Compose([
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI imagenet stats are: transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

gain.py Outdated
output_cl = self.model(data)
# тут раньше была сумма, но не думаю что она нужна в данном случае
grad_target = output_cl * label
grad_target[:, ill_index * 2].backward(gradient=label[:, ill_index * 2] * output_cl[:, ill_index * 2],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why gradient is multiplied by output_cl?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants