Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: deconv_length() missing 1 required positional argument: 'output_padding' #13

Closed
hiteshnitetc opened this issue Jul 5, 2019 · 13 comments

Comments

@hiteshnitetc
Copy link

Traceback (most recent call last):
File "./main.py", line 281, in
main(arguments)
File "./main.py", line 95, in main
model_list = create_model(args=args, input_shape=net_input_shape, enable_decoder=True)
File "/home/nd/capsnet/SegCaps-master (copy)/utils/model_helper.py", line 29, in create_model
model_list = CapsNetR3(input_shape, args.num_class, enable_decoder)
File "/home/nd/capsnet/SegCaps-master (copy)/segcapsnet/capsnet.py", line 55, in CapsNetR3
name='deconv_cap_1_1')(conv_cap_4_1)
File "/home/nd/anaconda3/lib/python3.6/site-packages/keras/engine/base_layer.py", line 457, in call
output = self.call(inputs, **kwargs)
File "/home/nd/capsnet/SegCaps-master (copy)/segcapsnet/capsule_layers.py", line 250, in call
out_height = deconv_length(self.input_height, self.scaling, self.kernel_size, self.padding)
TypeError: deconv_length() missing 1 required positional argument: 'output_padding'

@hiteshnitetc
Copy link
Author

Another problem is: "Too many indices for array, skipping files " , with 10 images and mask. but when i load MSCOCO data set with 10 images and mask it working.

@Cheng-Lin-Li
Copy link
Owner

Hi hiteshnitetc,

How many channels in your mask image? It should be only one channel as gray scale images.

@hiteshnitetc
Copy link
Author

@Cheng-Lin-Li Hello, yes my mask images are gray scale only, with channel 1, and keras is set to channel last topology

@AfsahS
Copy link

AfsahS commented Jul 12, 2019

I have same issue, code works fine with MSCOCO dataset, but have same error with different datasets.

@AfsahS
Copy link

AfsahS commented Jul 12, 2019

TypeError: deconv_length() missing 1 required positional argument: 'output_padding'.. This issue can be solved using keras=2.1.6 with python 3.6.x

@fenaux
Copy link

fenaux commented Jul 15, 2019

Hello,
I get the same issue
My configuration is : ubuntu 18.04.2, Python 3.6.7, Keras 2.2.4

The data were obtained with
python3 getcoco17.py --data_root_dir ../data --category person --annotation_file ../data/annotations/instances_train2017.json --number 10 --id 22228 178040 167494 144599 13800 147865 279422 477861 123512 69578

And then I run
python3 ./main.py --test --Kfold 2 --net segcapsr3 --data_root_dir=data --loglevel 2 --which_gpus=-2 --gpus=0 --dataset mscoco17 --weights_path data/saved_models/segcapsr3/split-0_batch-1_shuff-1_aug-0_loss-dice_slic-1_sub--1_strid-1_lr-0.0001_recon-20.0_model_20180705-092846.hdf5

thanks for your help

@fenaux
Copy link

fenaux commented Jul 15, 2019

Extract from
documentation of deconv_length line 148 and 149
https://github.com/keras-team/keras/blob/master/keras/utils/conv_utils.py
output_padding: Integer, amount of padding along the output dimension,
Can be set to None in which case the output length is inferred

Then I introduced the following modifications in "capsule_layers.py"
ddition on line 250 output_padding = None
New 251 (was 250) out_height = deconv_length(self.input_height, self.scaling, self.kernel_size, self.padding, output_padding)
New 252 (was 252) out_width = deconv_length(self.input_width, self.scaling, self.kernel_size, self.padding, output_padding)

addition on line 284 output_padding = None
new 285 (was 283) output_shape[1] = deconv_length(output_shape[1], self.scaling, self.kernel_size, self.padding, output_padding)
new 286 (was 284) output_shape[2] = deconv_length(output_shape[2], self.scaling, self.kernel_size, self.padding, output_padding)

and it seems it works. I get 5 output masks
But I now have an other issue : "Unable to find weights path. Testing with random weights".

@fenaux
Copy link

fenaux commented Jul 15, 2019

I found the solution :
In test.py
Line 109 weights_path = join(args.data_root_dir, args.weights_path)
then data should not be repeated in weight_path => command line modified accordingly
python3 ./main.py --test --Kfold 2 --net segcapsr3 --data_root_dir=data --loglevel 2 --which_gpus=-2 --gpus=0 --dataset mscoco17 --weights_path saved_models/segcapsr3/split-0_batch-1_shuff-1_aug-0_loss-dice_slic-1_sub--1_strid-1_lr-0.0001_recon-20.0_model_20180705-092846.hdf5

@hiteshnitetc
Copy link
Author

hiteshnitetc commented Jul 16, 2019 via email

@Cheng-Lin-Li
Copy link
Owner

Hi fenaux,

Thanks for your findings and suggestions.
I will revise the document and code accordingly.

@tanchaozhen
Copy link

I get the same issue.
I solved the first problem "deconv_length() missing " using keras=2.1.6 with python 3.6.x.
But,"Too many indices for array, skipping files" still cannot be solved. Have you solved it?

@nithinivi
Copy link

TypeError: deconv_length() missing 1 required positional argument: 'output_padding'.. This issue can be solved using keras=2.1.6 with python 3.6.x

If using the latest version of Keras please use output_padding=None, this seems to solve the issue

@hiteshnitetc
Copy link
Author

Getting following error.

INFO 2020-12-25 19:49:37,131: 
path_to_np=data/np_files/train18.npz
INFO 2020-12-25 19:49:37,132: 
Pre-made numpy array not found for train18.
Creating now...
DEBUG 2020-12-25 19:49:37,132: STREAM b'IHDR' 16 13
DEBUG 2020-12-25 19:49:37,132: STREAM b'IDAT' 41 32768

----------------------------------------------------------------------------------------------------
Unable to load img or masks for train18
too many indices for array: array is 2-dimensional, but 3 were indexed
Skipping file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants