Code Monkey home page Code Monkey logo

chainer-center-loss's Introduction

Chainer Center Loss

Implementation of Center Loss in Chainer.

Requirements

  • Python 3.5.1
  • Chainer 2.0.0
  • CuPy 1.0.0 (if use GPU)
  • Matplotlib

How to train

  • with CPU and use center loss
python train_mnist.py --batchsize 32 --epoch 20 --centerloss
  • with GPU and use center loss
python train_mnist.py --batchsize 32 --epoch 20 --gpu 0 --centerloss

Visualize the result

  • MNIST, Softmax Loss + Center Loss
    The white dots denote 10 class centers of deep features.

Figure 1

  • MNIST, only Softmax Loss

Figure 2

Reference

chainer-center-loss's People

Contributors

nyk510 avatar shunk031 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nyk510

chainer-center-loss's Issues

ValueError: Broadcasting failed

hey,
I am using my own dataset and getting the following error,
Traceback (most recent call last):
File "train_mnist.py", line 177, in
main()
File "train_mnist.py", line 173, in main
trainer.run()
File "/home/ram/sanaa/local/lib/python2.7/site-packages/chainer/training/trainer.py", line 313, in run
six.reraise(*sys.exc_info())
File "/home/ram/sanaa/local/lib/python2.7/site-packages/chainer/training/trainer.py", line 299, in run
update()
File "/home/ram/sanaa/local/lib/python2.7/site-packages/chainer/training/updater.py", line 223, in update
self.update_core()
File "/home/ram/sanaa/local/lib/python2.7/site-packages/chainer/training/updater.py", line 234, in update_core
optimizer.update(loss_func, *in_arrays)
File "/home/ram/sanaa/local/lib/python2.7/site-packages/chainer/optimizer.py", line 536, in update
loss = lossfun(*args, **kwds)
File "/home/ram/sanaa/workspace/style_occasion/sanaa/train_conv/train_conv_multi/chainer-center-loss-master/model.py", line 49, in call
center_loss = self.center_loss_function(h, t)
File "/home/ram/sanaa/workspace/style_occasion/sanaa/train_conv/train_conv_multi/chainer-center-loss-master/center_loss.py", line 78, in call
return CenterLossFunction(self.alpha, self.num_classes)(x, t, self.centers)
File "/home/ram/sanaa/local/lib/python2.7/site-packages/chainer/function.py", line 235, in call
ret = node.apply(inputs)
File "/home/ram/sanaa/local/lib/python2.7/site-packages/chainer/function_node.py", line 245, in apply
outputs = self.forward(in_data)
File "/home/ram/sanaa/local/lib/python2.7/site-packages/chainer/function.py", line 135, in forward
return self._function.forward(inputs)
File "/home/ram/sanaa/workspace/style_occasion/sanaa/train_conv/train_conv_multi/chainer-center-loss-master/center_loss.py", line 39, in forward
y = xp.sum(xp.square(features - centers_batch)) / batch_size / 2
File "cupy/core/core.pyx", line 1185, in cupy.core.core.ndarray.sub
File "cupy/core/elementwise.pxi", line 798, in cupy.core.core.ufunc.call
File "cupy/core/core.pyx", line 2308, in cupy.core.core.broadcast.init
ValueError: Broadcasting failed
help would be appreciated!
thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.