deeplearningturkiye / kapsul-agi-capsule-network Goto Github PK
View Code? Open in Web Editor NEWProf. Geoffrey Hinton’ın “Dynamic Routing Between Capsules” makalesindeki Kapsül Ağı (Capsule Network: CapsNet) algoritmasının Keras Uygulamasıdır.
Prof. Geoffrey Hinton’ın “Dynamic Routing Between Capsules” makalesindeki Kapsül Ağı (Capsule Network: CapsNet) algoritmasının Keras Uygulamasıdır.
İyi Çalışmalar.
Normal şartlarda kodu kendim alıp modifiye ettiğim halinde el yapımı bir veri kümesinde başarı ile çalıştırdım. Fakat Mnist içinde denemek istedim. Kodu tavsiye ettiğiniz şekillde çalıştırınca ;
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 1152 and 16 for 'digitcaps/add_2' (op: 'AddV2') with input shapes: [?,10,?,1152], [?,10,10,1152,16,10,?,16].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "capsulenet.py", line 206, in
num_routing=args.num_routing)
File "capsulenet.py", line 44, in CapsNet
name='digitcaps')(primarycaps)
File "/usr/local/lib/python3.6/dist-packages/keras/engine/base_layer.py", line 451, in call
output = self.call(inputs, **kwargs)
File "/content/kapsul-agi-capsule-network/capsulelayers.py", line 167, in call
b += K.batch_dot(outputs, inputs_hat_stopped, [2, 3])
File "/tensorflow-1.15.0/python3.6/tensorflow_core/python/ops/math_ops.py", line 899, in binary_op_wrapper
return func(x, y, name=name)
File "/tensorflow-1.15.0/python3.6/tensorflow_core/python/ops/math_ops.py", line 1197, in _add_dispatch
return gen_math_ops.add_v2(x, y, name=name)
File "/tensorflow-1.15.0/python3.6/tensorflow_core/python/ops/gen_math_ops.py", line 549, in add_v2
"AddV2", x=x, y=y, name=name)
File "/tensorflow-1.15.0/python3.6/tensorflow_core/python/framework/op_def_library.py", line 794, in _apply_op_helper
op_def=op_def)
File "/tensorflow-1.15.0/python3.6/tensorflow_core/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/tensorflow-1.15.0/python3.6/tensorflow_core/python/framework/ops.py", line 3357, in create_op
attrs, op_def, compute_device)
File "/tensorflow-1.15.0/python3.6/tensorflow_core/python/framework/ops.py", line 3426, in _create_op_internal
op_def=op_def)
File "/tensorflow-1.15.0/python3.6/tensorflow_core/python/framework/ops.py", line 1770, in init
control_input_ops)
File "/tensorflow-1.15.0/python3.6/tensorflow_core/python/framework/ops.py", line 1610, in _create_c_op
raise ValueError(str(e))
ValueError: Dimensions must be equal, but are 1152 and 16 for 'digitcaps/add_2' (op: 'AddV2') with input shapes: [?,10,?,1152], [?,10,10,1152,16,10,?,16].
Şu Hatayı aldım. Çözmeye uğraşacağım. Bilginize. Ellerinize sağlık
İyi güzel, commentleri Türkçeleştirmişsiniz de kodu gerçekten yazmış kişiye referans verin bari:
https://github.com/XifengGuo/CapsNet-Keras
Hani bilim, etik vs.
Kodu olduğu gibi, üzerinde hiçbir değişiklik yapmadan çalıştırmak istediğimde "TypeError: unsupported operand type(s) for *=: 'int' and 'NoneType'" hatası aldım. Traceback aşağıdaki gibidir.
Sorunun kaynadığını henüz bulamadım. Bulan ve çözen olursa yardımcı olabilirse çok sevinirim.
Traceback (most recent call last):
File "capsulenet.py", line 206, in
model, eval_model = CapsNet(input_shape=x_train.shape[1:],
File "capsulenet.py", line 43, in CapsNet
digitcaps = CapsuleLayer(num_capsule=n_class, dim_capsule=16, num_routing=num_routing,
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 897, in call
self._maybe_build(inputs)
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 2416, in _maybe_build
self.build(input_shapes) # pylint:disable=not-callable
File "/storage/selin/Works/kapsul-agi-capsule-network/capsulelayers.py", line 112, in build
self.W = self.add_weight(shape=[self.num_capsule, self.input_num_capsule,
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 560, in add_weight
variable = self._add_variable_with_custom_getter(
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py", line 738, in _add_variable_with_custom_getter
new_variable = getter(
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer_utils.py", line 129, in make_variable
return tf_variables.VariableV1(
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 259, in call
return cls._variable_v1_call(*args, **kwargs)
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 205, in _variable_v1_call
return previous_getter(
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 198, in
previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs)
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/variable_scope.py", line 2584, in default_variable_creator
return resource_variable_ops.ResourceVariable(
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 263, in call
return super(VariableMetaclass, cls).call(*args, **kwargs)
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 1423, in init
self._init_from_args(
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 1567, in _init_from_args
initial_value() if init_from_fn else initial_value,
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer_utils.py", line 121, in
init_val = lambda: initializer(shape, dtype=dtype)
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/init_ops_v2.py", line 545, in call
fan_in, fan_out = _compute_fans(scale_shape)
File "/storage/selin/miniconda3/envs/tf2/lib/python3.8/site-packages/tensorflow/python/ops/init_ops.py", line 1422, in _compute_fans
receptive_field_size *= dim
TypeError: unsupported operand type(s) for *=: 'int' and 'NoneType'
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.