keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.96k stars 19.46k forks source link

Conv2D TypeError: __init()__ takes at least 4 arguments (4 given) #5901

Closed ankitsharma285 closed 7 years ago

ankitsharma285 commented 7 years ago

I am learning to use Keras's Functional API . I tried running one of code snippet (ex: inception module ) from the documentation (https://keras.io/getting-started/functional-api-guide/). I get the above mentioned error. I tried running other code snippets as well from the documentation. I get same error for each one.


Inception Module code snippet from the docs:

from keras.layers import Conv2D, MaxPooling2D, Input

input_img = Input(shape=(256, 256,3))

tower_1 = Conv2D(64, (1, 1), padding='same', activation='relu')(input_img) tower_1 = Conv2D(64, (3, 3), padding='same', activation='relu')(tower_1)

tower_2 = Conv2D(64, (1, 1), padding='same', activation='relu')(input_img) tower_2 = Conv2D(64, (5, 5), padding='same', activation='relu')(tower_2)

tower_3 = MaxPooling2D((3, 3), strides=(1, 1), padding='same')(input_img) tower_3 = Conv2D(64, (1, 1), padding='same', activation='relu')(tower_3)

output = keras.layers.concatenate([tower_1, tower_2, tower_3], axis=1)

I am trying to use Conv2D as the first layer in functional API setting. Can anyone please provide me some suggestion on how to resolve this issue?

Thank you.

Ankit Sharma.

ramanb25 commented 7 years ago

Have you checked your keras version?

Consider upgrading as the API call has been changed.

sudo pip install --upgrade keras

ankitsharma285 commented 7 years ago

@ramanb25: I did the same few hours back. The issue got resolved. Thank you for your suggestion.

danae2hyr commented 7 years ago

I have the same problem as you, could you tell me how to solve this issue? Thanks

SilverJacket commented 6 years ago

@ramanb25 Where do I type that command? I'm using a Jupyter notebook on AWS. In my shell, I shut down the notebook in order to access my ubuntu command line (while ssh'ed into the AWS server) and typed that line, but it said "sudo: pip: command not found". Thanks.

SabariRaaj commented 5 years ago

x1 = Conv2D(16, (4, 4), strides=(2, 2), activation='relu')(input_1) TypeError: init() takes at least 4 arguments (4 given) This is the error I'm getting, I tried upgrading keras and tensorflow versions but nothing seems to be effective. Please give me some solution

brotheryun commented 5 years ago

@SabariRaaj Me too!Could you tell me how to solve this issue?

SabariRaaj commented 4 years ago

@SabariRaaj Me too!Could you tell me how to solve this issue?

@brotheryun Bro just use the following versions, keras 2.1.5 and tensorflow 1.5.0. only these versions matched perfectly and solved my issue. These versions are for python 3.