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

GetReal not working #32

Open
SpenceraM opened this issue Jul 9, 2018 · 1 comment
Open

GetReal not working #32

SpenceraM opened this issue Jul 9, 2018 · 1 comment

Comments

@SpenceraM
Copy link

I am trying to add a complex dense layer to the deep network

def get_deep_convnet(window_size=4096, channels=2, output_size=84):
    print"start model"
    inputs = Input(shape=(window_size, channels))
    print "input shape is (", window_size,",", channels,")"
    outs = inputs 
    outs = (ComplexConv1D(
        16, 6, strides=2, padding='same',
        activation='linear',
        kernel_initializer='complex_independent'))(outs)
    outs = (ComplexBN(axis=-1))(outs)
    outs = (keras.layers.Activation('relu'))(outs)
    outs = (keras.layers.AveragePooling1D(pool_size=2, strides=2))(outs)
    outs = (ComplexConv1D(
        32, 3, strides=2, padding='same',
        activation='linear',
        kernel_initializer='complex_independent'))(outs)
    outs = (ComplexBN(axis=-1))(outs)
    outs = (keras.layers.Activation('relu'))(outs)
    outs = (keras.layers.AveragePooling1D(pool_size=2, strides=2))(outs)
    
    outs = (ComplexConv1D(
        64, 3, strides=1, padding='same',
        activation='linear',
        kernel_initializer='complex_independent'))(outs)
    outs = (ComplexBN(axis=-1))(outs)
    outs = (keras.layers.Activation('relu'))(outs)
    outs = (keras.layers.AveragePooling1D(pool_size=2, strides=2))(outs)

    outs = (ComplexConv1D(
        64, 3, strides=1, padding='same',
        activation='linear',
        kernel_initializer='complex_independent'))(outs)
    outs = (ComplexBN(axis=-1))(outs)
    outs = (keras.layers.Activation('relu'))(outs)
    outs = (keras.layers.AveragePooling1D(pool_size=2, strides=2))(outs)

    outs = (ComplexConv1D(
        128, 3, strides=1, padding='same',
        activation='relu',
        kernel_initializer='complex_independent'))(outs)
    outs = (ComplexConv1D(
        128, 3, strides=1, padding='same',
        activation='linear',
        kernel_initializer='complex_independent'))(outs)
    outs = (ComplexBN(axis=-1))(outs)
    outs = (keras.layers.Activation('relu'))(outs)
    outs = (keras.layers.AveragePooling1D(pool_size=2, strides=2))(outs)

    outs = (keras.layers.MaxPooling1D(pool_size=2))(outs)#com
    outs = (Permute([2, 1]))(outs)#com
    flattened = Flatten()(outs)

    dense = ComplexDense(2048, activation='relu')(flattened) #new from here
    predictions = ComplexDense(
        output_size, 
        activation='sigmoid',
        bias_initializer=Constant(value=-5))(dense)
    predictions = GetReal(predictions)
    model = Model(inputs=inputs, outputs=predictions)
    model.compile(optimizer=keras.optimizers.Adam(lr=1e-4),
                  loss='binary_crossentropy',
                  metrics=['accuracy'])
    print "end model"
    return model

The addition here is where I add the ComplexDense() and define it as 'dense'.
The following error error is printed:

.. building model
.. complex network
.. using deep convnet
start model
input shape is ( 4096 , 2 )
Traceback (most recent call last):
  File "scripts/train.py", line 147, in <module>
    main(**parser.parse_args().__dict__)
  File "scripts/train.py", line 105, in main
    model = get_model(model, dataset.feature_dim)
  File "scripts/train.py", line 80, in get_model
    channels=feature_dim[1])
  File "/home/my_name/Dvlp/py2venvs/test_env/local/lib/python2.7/site-packages/musicnet/models/complex/__init__.py", line 107, in get_deep_convnet
    predictions = GetReal(predictions)
TypeError: __init__() takes exactly 1 argument (2 given)

@enginsheer
Copy link

In case it is useful to someone, change GetReal(predictions) to GetReal()(predictions)

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

2 participants