naturomics / CapsNet-Tensorflow

A Tensorflow implementation of CapsNet(Capsules Net) in paper Dynamic Routing Between Capsules
Apache License 2.0
3.8k stars 1.17k forks source link

TypeError: reduce_sum() got an unexpected keyword argument 'keepdims' #64

Closed pulins201 closed 6 years ago

ZhiboRao commented 6 years ago

I have met the same question.

ZhiboRao commented 6 years ago

I find you can fix the capsLayer.py. In 129, you delete the "keepdims=True". Then it works.

pulins201 commented 6 years ago

ok

vidzrox commented 6 years ago

It should be written as "keep_dims=True"

sks4world commented 4 years ago

I'm getting the same error when following this github code https://github.com/akosiorek/akosiorek.github.io/blob/master/notebooks/attention_glimpse.ipynb How can I fix this? I'm stuck

Jupyter notebook:

Gaussian Attention

gaussian_att_params = tf.concat([tu, ts, td, tu, ts, td], -1) gaussian_glimpse_expr = gaussian_glimpse(tx, gaussian_att_params, glimpse_size)

Upon running error: TypeError Traceback (most recent call last)

in 1 # Gaussian Attention 2 gaussian_att_params = tf.concat([tu, ts, td, tu, ts, td], -1) ----> 3 gaussian_glimpse_expr = gaussian_glimpse(tx, gaussian_att_params, glimpse_size) in gaussian_glimpse(img_tensor, transform_params, crop_size) 29 uy, sy, dy, ux, sx, dx = tf.split(transform_params, 6, split_ax) 30 # create Gaussian masks, one for each axis ---> 31 Ay = gaussian_mask(uy, sy, dy, h, H) 32 Ax = gaussian_mask(ux, sx, dx, w, W) 33 # extract glimpse in gaussian_mask(u, s, d, R, C) 14 mask = tf.exp(-.5 * tf.square(column_centres / s)) 15 # we add eps for numerical stability ---> 16 normalised_mask = mask / (tf.reduce_sum(mask, 1, keep_dims=True) + 1e-8) 17 return normalised_mask 18 ~\Anaconda2\envs\PythonCPU\lib\site-packages\tensorflow_core\python\util\dispatch.py in wrapper(*args, **kwargs) 178 """Call target, and fall back on dispatchers if there is a TypeError.""" 179 try: --> 180 return target(*args, **kwargs) 181 except (TypeError, ValueError): 182 # Note: convert_to_eager_tensor currently raises a ValueError, not a TypeError: reduce_sum() got an unexpected keyword argument 'keep_dims'