Comments (14)
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.
Thanks a lot.
from capsule.
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.
@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.
@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.
@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.
@ymcui you mean batch_dot has a different performance with theano backend?
from capsule.
@ymcui you are right. I got it. thanks very much.
from capsule.
You're welcome :)
from capsule.
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.
@wuzy361 which backend?
from capsule.
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.
@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.
@bojone
Thanks,I will try it.
from capsule.
Related Issues (15)
- 如何将Capsule用于NLP问题
- 当我用python3执行的时候遇到一个问题 HOT 2
- Capsule可否用于regression的问题
- why reshape before capsule
- 使用keras2.2.4运行时遇到一个问题 HOT 2
- why relu after primary caps ?
- 关于conv1d,和local_conv1d,softmax层以及胶囊中池化层的问题 HOT 4
- squash function HOT 9
- 想问下Hinton版的 Capsule 在“单数字训练、双数字测试”的准确率有多少? HOT 2
- Meeting an error HOT 5
- About Primary Capsule HOT 1
- loss为nan HOT 5
- capsule 类中的b没有更新 HOT 3
- 关于capsule的输出问题 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from capsule.