XifengGuo / CapsNet-Keras

A Keras implementation of CapsNet in NIPS2017 paper "Dynamic Routing Between Capsules". Now test error = 0.34%.
MIT License
2.46k stars 652 forks source link

How to run capsule model for regression problem? #79

Closed rezazad68 closed 5 years ago

rezazad68 commented 6 years ago

Hi,

I would like to use a capsule model for the regression problem in which I have an input image with a shape similar to MNIST but with a label (vector length 40). which part of the code I should change for being able to run this model for the regression problem? Thanks

shape (x_train) = (5000, 28, 28, 1) shape(y_train) = (5000, 40)

fastesol commented 5 years ago

Do you have have a logic on paper for this?

DandiC commented 5 years ago

I worked on a project in which we substituted the reconstruction layer by a regression layer and got very good results. You can check the details here: https://scholar.google.com/scholar?hl=en&as_sdt=0%2C47&q=Deepcoast&btnG=#d=gs_qabs&p=&u=%23p%3DDnqc7fiIYOwJ

rezazad68 commented 5 years ago

I worked on a project in which we substituted the reconstruction layer by a regression layer and got very good results. You can check the details here: https://scholar.google.com/scholar?hl=en&as_sdt=0%2C47&q=Deepcoast&btnG=#d=gs_qabs&p=&u=%23p%3DDnqc7fiIYOwJ

Thanks for the reply. Does your implementation is online available? I just need to edit the capsule implementation in kers for the regression problem.

XifengGuo commented 5 years ago

@rezazad68 I think you can just change the loss from ['margin_loss', 'mse'] to ['mse', 'mse']. https://github.com/XifengGuo/CapsNet-Keras/blob/923809b82a859ec26dd533fb015546817a3d3f11/capsulenet.py#L114