Search code examples
pythontensorflowkeras-layer

TypeError: __init__() takes exactly 2 arguments (3 given) when I try to permute


How shall I permute rows and columns properly in the following example?

input_shape = (input_dim, input_features)
inputs = Input(input_shape)
net = Reshape(input_shape + (1, ), input_shape=input_shape)(inputs)

net is passed to Conv2D.

When I use inpute_shape = Permute(2,1) I got the error __init__() takes exactly 2 arguments (3 given)

Thanks!

This is the recent Traceback after I tried some options:

Traceback (most recent call last):
  File "app.py", line 372, in <module>
    train(model_filename=args.model, epochs=args.epochs, dim=args.dim)
  File "app.py", line 61, in train
    output_classes=reader.CLASSES)
  File "/home/ubuntu/calypso_v2/model.py", line 53, in build_model
    net = Permute(3,2)(net)
TypeError: __init__() takes exactly 2 arguments (3 given)

Solution

  • Permute() takes a tuple as its only positional argument. Instead of the tuple (2,1), you've specified the two ints 2, and 1.

    Try this:

    inpute_shape = Permute((2,1))