kakoedlinnoeslovo / center_loss Goto Github PK
View Code? Open in Web Editor NEWHere is my implementation of Center Loss with Keras
Here is my implementation of Center Loss with Keras
Hi, thanks for your implement, but I have some problem about this, hope you can help me.
First, why it said "Train on 18000 samples, validate on 10000 samples", because I think we input 60000 samples for training?
Second, If we want to know the accuracy, we should only concern the val_dense_2_acc or we should concern both val_dense_2_acc and val_centerlosslayer_acc? And why val_centerlosslayer_acc always 1.0?
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?
Hi Kakoedlinnoeslovo,
Thanks for the code. I am trying to implement center-loss in Tensorflow 2.0 and found that some arguments in self.add_update are deprecated. It does not throw any error, but the centers are never updated.
You can find the description here:
https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/keras/engine/base_layer.py#L1170-L1259
Can you provide a work around for this?
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.