-
Notifications
You must be signed in to change notification settings - Fork 2
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
about the centre_loss #1
Comments
Hello, @longzeyilang, yes, when we write call function we just write the rules of how our value will be computed, so than if we want to apply our CenterLoss, we specify it in the compile() function. |
I have some problem when I use centerloss in image classification with keras.
y_train is the labels. If I do like this custom_vgg_model.fit(y = {'fc2':dummy1,'predictions':y_train}),the model will train successful. The dummy1 have same shape with 'fc2' output(feature).
|
Hi, I have a question:
def call(self, x, mask=None): ## x[0] is Nx2, x[1] is Nx10 onehot, self.centers is 10x2 delta_centers = K.dot(K.transpose(x[1]), (K.dot(x[1], self.centers) - x[0])) # 10x2 denominator = K.sum(K.transpose(x[1]), axis=1, keepdims=True) + 1 delta_centers /= denominator new_centers = self.centers - self.alpha_center * delta_centers self.add_update((self.centers, new_centers), x) self.result = (K.dot(x[1], self.centers) - x[0]) self.result = K.sum(self.result ** 2, axis=1, keepdims=True) return self.result
the call function has already contained the center loss. But in the below:
self.model.compile(optimizer=optimizer, loss=[losses.categorical_crossentropy, self.center_loss], loss_weights=[1, self.lambda_centerloss])
the compile get center_loss again and again, is that true?
The text was updated successfully, but these errors were encountered: