Code Monkey home page Code Monkey logo

Comments (14)

bojone avatar bojone commented on June 30, 2024 1

oh, sorry. I has not any experience about theano.
it seems that T.nnet.softmax only support 1-d or 2-d tensor. but keras.io do not show it.

I will try to fix it but I am sure about it.

from capsule.

jcjview avatar jcjview commented on June 30, 2024

Thanks a lot.

from capsule.

bojone avatar bojone commented on June 30, 2024

now I change the code, and I build the capsule model successfully with Keras + theano, but error while training with model.fit. I has debuged long time but can not find the reason.

If you can work out, please tell me.

from capsule.

ymcui avatar ymcui commented on June 30, 2024

@bojone
Maybe it's about the wrong output shape of the K.batch_dot(), which is a Runtime Error

        for i in range(self.routings):
            c = softmax(b, 1)
            outputs = self.activation(K.batch_dot(c, u_hat_vecs, [2, 2]))   # outputs.shape = [None, num_capsule, num_capsule, dim_capsule]
            if i < self.routings - 1:
                b = K.batch_dot(outputs, u_hat_vecs, [2, 3])

the outputs's shape does not match the output of compute_output_shape.

Best,
Yiming

from capsule.

bojone avatar bojone commented on June 30, 2024

@ymcui
c.shape is [None, num_capsule, input_num_capsule]
u_hat_vecs.shape = [None, num_capsule, input_num_capsule, dim_capsule]
batch_dot of them has shape of [None, num_capsule, dim_capsule]
why do you think of [None, num_capsule, num_capsule, dim_capsule] ?

from capsule.

ymcui avatar ymcui commented on June 30, 2024

@bojone Maybe you can have a try with toy tensor.
The result should be the shape that I have posted.
Your error results from the runtime error on shape.
Just a quick fix: https://github.com/ymcui/Capsule/blob/master/Capsule_Keras.py

from capsule.

bojone avatar bojone commented on June 30, 2024

@ymcui you mean batch_dot has a different performance with theano backend?

from capsule.

bojone avatar bojone commented on June 30, 2024

@ymcui you are right. I got it. thanks very much.

from capsule.

ymcui avatar ymcui commented on June 30, 2024

You're welcome :)

from capsule.

wuzy361 avatar wuzy361 commented on June 30, 2024

when I run "python capsule_test.py",there is some error as follows:
Traceback (most recent call last):
File "capsule_test.py", line 82, in
cnn = Reshape((-1, 128))(cnn)
File "/usr/local/lib/python2.7/dist-packages/Keras-2.0.2-py2.7.egg/keras/engine/topology.py", line 554, in call
output = self.call(inputs, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Keras-2.0.2-py2.7.egg/keras/layers/core.py", line 402, in call
target_shape = self.compute_output_shape(input_shape)[1:]
File "/usr/local/lib/python2.7/dist-packages/Keras-2.0.2-py2.7.egg/keras/layers/core.py", line 385, in compute_output_shape
input_shape[1:], self.target_shape)
File "/usr/local/lib/python2.7/dist-packages/Keras-2.0.2-py2.7.egg/keras/layers/core.py", line 373, in _fix_unknown_dimension
original = np.prod(input_shape, dtype=int)
File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 2518, in prod
out=out, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/numpy/core/_methods.py", line 35, in _prod
return umr_prod(a, axis, dtype, out, keepdims)
TypeError: long() argument must be a string or a number, not 'NoneType'

I update keras,but the error remains,please help me

from capsule.

bojone avatar bojone commented on June 30, 2024

@wuzy361 which backend?

from capsule.

zhangjunwang avatar zhangjunwang commented on June 30, 2024

using tensorflow backend.

when I run "python capsule_test.py",there is some error as follows:
Traceback (most recent call last):
File "capsule_test.py", line 83, in
capsule = Capsule(10, 16, 3, True)(cnn)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 619, in call
output = self.call(inputs, **kwargs)
File "/home/zhangjunwang/Capsule1/Capsule_Keras.py", line 71, in call
o = K.l2_normalize(o, -1)
File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 3151, in l2_normalize
return tf.nn.l2_normalize(x, axis=axis)
TypeError: l2_normalize() got an unexpected keyword argument 'axis'

please help me!Thanks

from capsule.

bojone avatar bojone commented on June 30, 2024

@zhangjunwang
your keras and tensorflow must be updated to lastest version.
the problem is resulted from that your tensorflow version is lower than the keras needed.

from capsule.

zhangjunwang avatar zhangjunwang commented on June 30, 2024

@bojone
Thanks,I will try it.

from capsule.

Related Issues (15)

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.