-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dont know how to apply centerloss to my own project #12
Comments
Your question is quite ambiguous. But I think it was probably caused by a high LR or a high loss weight which makes gradient descent optimization failed. |
Have you found a solution to your problem? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want to use ResNet50 as my model and change Fully Connection layer to classify images.
#Create model:
model = models.resnet50(pretrained=True)
fc_inputs = model.fc.in_features
class FClayer(nn.Module):
def init(self):
super(FClayer, self).init()
self.fc1 = nn.Linear(fc_inputs, 2)
self.relu1 = nn.ReLU()
self.fc2 = nn.Linear(2, num_classes)
def forward(self, x):
x = self.relu1(self.fc1(x))
y = self.fc2(x)
return x, y
model.fc = FClayer()
...
#In train function:
features, outputs = model(inputs)
alpha = 1
loss = loss_criterion(outputs, labels) + (loss_criterion_cent(features, labels) * alpha)
optimizer.zero_grad()
optimizer_cent.zero_grad()
loss.backward()
optimizer.step()
for param in loss_criterion_cent.parameters():
param.grad.data *= (1./alpha)
optimizer_cent.step()
I dont know why when i was training, at the very first epochs, the accuracy had increased, but soon later, nothing happended. Here is my accuracy plot curve chart:
![Sign_accuracy_curve](https://user-images.githubusercontent.com/46515998/63987608-12aa4580-cb03-11e9-95d5-99a27ea8994f.png)
Do I have something wrong?
The text was updated successfully, but these errors were encountered: