Giter Site home page Giter Site logo

deep_complex_networks's People

Contributors

chihebtrabelsi avatar dmitriy-serdyuk avatar obilaniu avatar oisinmoran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deep_complex_networks's Issues

Windows support

When I install requirements for music experiments, it gives me this error, please help me, thanks

(D:\anaconda3) C:\Users\123>pip install git+git://github.com/bartvm/mimir.git
Collecting git+git://github.com/bartvm/mimir.git
Cloning git://github.com/bartvm/mimir.git to c:\users\123\appdata\local\temp\pip-4md_br_o-build
Requirement already satisfied: pyzmq in d:\anaconda3\lib\site-packages (from mimir==0.1.dev1)
Requirement already satisfied: six in d:\anaconda3\lib\site-packages (from mimir==0.1.dev1)
Requirement already satisfied: simplejson in d:\anaconda3\lib\site-packages (from mimir==0.1.dev1)
Installing collected packages: mimir
Running setup.py install for mimir ... error
Complete output from command d:\anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\123\AppData\Local\Temp\pip-4md_br_o-build\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\123\AppData\Local\Temp\pip-crye2e8k-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\mimir
copying mimir\formatters.py -> build\lib.win-amd64-3.6\mimir
copying mimir\handlers.py -> build\lib.win-amd64-3.6\mimir
copying mimir\logger.py -> build\lib.win-amd64-3.6\mimir
copying mimir\plot.py -> build\lib.win-amd64-3.6\mimir
copying mimir\remote.py -> build\lib.win-amd64-3.6\mimir
copying mimir\serialization.py -> build\lib.win-amd64-3.6\mimir
copying mimir\stream.py -> build\lib.win-amd64-3.6\mimir
copying mimir\utils.py -> build\lib.win-amd64-3.6\mimir
copying mimir_init_.py -> build\lib.win-amd64-3.6\mimir
running build_ext
error: [WinError 2] 系统找不到指定的文件。

----------------------------------------

Command "d:\anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\123\AppData\Local\Temp\pip-4md_br_o-build\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\123\AppData\Local\Temp\pip-crye2e8k-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\123\AppData\Local\Temp\pip-4md_br_o-build\

Missing tensorflow dependency

When running the first experiment, training.py imports complexnn, which imports keras, which imports tensorflow (but somehow tensorflow wasn't installed during setup)

Is the learn imaginary data really work?

In the paper,the author wrote

"since all datasets that we work with have real-valued inputs, we present a way to learn their imaginary components to let the rest of the network operate in the complex plane".

In my view, i just wonder why we cannot use the fft data based on the input image but using the imaginary data learned from the convolutional layer?

question about data_path

Hello,
I'm trying to run the complex model on cifar-10 dataset,but errors occur like this:
image
I've typed the '-d $datapath' in the command,then I went to check the argparser as the error mentioned,but I still cannot figure it out.
I'm really sorry to interrupt you,and really expect a explanation of the error.
Best wishes.
Thanks a lot.

about training

image
How to solve this problem:Attribute error:'int' object has no attribute 'dtype'? Thanks

Problem occurring at the projection concatenation.

Dear all,

I feel like you have made a mistake (or let a test value on the code :) ) on at the line 128 of training.py, indeed I think that the concatenation should be on the same axis as the two previous one so channel_axis and not this value. When I'm using 1 such as in the code I get a weird tensor shape like (32,16,44) while I should have (16,16,44).

Hope that will help !

Multiple CPUs?

Is there any way to run the code on multiple CPUs or GPUs?

AttributeError: 'module' object has no attribute 'Logger'

Hi,
When I try to run python scripts/train.py shallow_model --in-memory --model=shallow_convnet --local-data data/musicnet_11khz.npz in the musicnet/ folder, I encounter the following error:

Traceback (most recent call last): File "scripts/train.py", line 142, in <module> main(**parser.parse_args().__dict__) File "scripts/train.py", line 111, in main logger = mimir.logger( AttributeError: 'module' object has no attribute 'logger'

I then openpython and do:import mimir; mimir.Logger(maxlen=10)
The same error occurs:
Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'Logger'
I have checked the docs of mimir and didn't find this issue. May I ask what the problem might be? Thanks!

'int' object has no attribute 'dtype'

Hi,
When I try to python scripts/run.py train -d ./data/ -w ./ --model complex --sf 5 --nb 5 it throws the following error. Whats the fix?

screenshot from 2017-06-18 16-09-47

These are my model parameters and system settings

modelp

Thank you

Mímir IOError

After running all the commands exactly as shown in the README.md, when executing the first line of step 2 in the MusicNet section, notably:

train.py shallow_model --in-memory --model=shallow_convnet --local-data data/musicnet_11khz.npz

I am getting this error:

Traceback (most recent call last):
  File "/home/oisin/DCN/bin/train.py", line 4, in <module>
    __import__('pkg_resources').run_script('DeepComplexNetworks==1', 'train.py')
  File "/home/oisin/DCN/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 750, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/home/oisin/DCN/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1534, in run_script
    exec(script_code, namespace, namespace)
  File "/home/oisin/DCN/local/lib/python2.7/site-packages/DeepComplexNetworks-1-py2.7.egg/EGG-INFO/scripts/train.py", line 142, in <module>
    
  File "/home/oisin/DCN/local/lib/python2.7/site-packages/DeepComplexNetworks-1-py2.7.egg/EGG-INFO/scripts/train.py", line 112, in main
    
  File "/home/oisin/DCN/local/lib/python2.7/site-packages/mimir/logger.py", line 71, in Logger
    handlers.append(GzipJSONHandler(root))
  File "/home/oisin/DCN/local/lib/python2.7/site-packages/mimir/handlers.py", line 134, in __init__
    stream = gzlog.GZipLog(filename)
  File "gzlog/gzlog.pyx", line 89, in mimir.gzlog.GZipLog.__init__
  File "gzlog/gzlog.pyx", line 26, in mimir.gzlog.Gzlog.__cinit__
IOError

I am running this in a virtual environment with Python 2.7 and my ~/.keras/keras.json looks like:

{
    "backend": "theano",
    "epsilon": 1e-07,
    "floatx": "float32",
    "image_data_format": "channels_last"
}

Any help at all in trying to fix this would be greatly appreciated.

About the version of library to be imported

Hi, I download your codes and try to run the run.py such as the following command:
python scripts/run.py train --model complex --sf 12 --nb 16
However, I have tried the keras version from 2.2.4 to 2.2.0, 2.1.6 2.0.6 ,even to 1.1.0 1.2.0 but it seems that the code part K.sqrt(2) in your code
def sqrt_init(shape, dtype=None): value = (1 / K.sqrt(2)) * K.ones(shape) return value (in complexBN/bn.py)
always error such as :
AttributeError: 'int' object has no attribute 'dtype'

about load model

image
image

how to solve this problem: 'ValueError: Unknown initializer: sqrt_init'

Using your own dataset.

I just wanted to know how might i go about using this with my own dataset. The format of said set is currently a .txt file.

utilsextension DLL load failed

have installed setup.py, but met with the problem
Using Theano backend. Traceback (most recent call last): File "scripts/run.py", line 237, in <module> main(sys.argv) File "scripts/run.py", line 235, in main return d.__subcmdfn__(d) File "scripts/run.py", line 193, in run import training;training.train(d) File "E:\Python_Project\Python2.7\ComplexNet\deep_complex_networks-master\scripts\training.py", line 28, in <module> from kerosene.datasets import svhn2 File "E:\Program\Anaconda2\envs\ComplexNet\lib\site-packages\kerosene\datasets\svhn2.py", line 2, in <module> import fuel.datasets File "E:\Program\Anaconda2\envs\ComplexNet\lib\site-packages\fuel\datasets\__init__.py", line 5, in <module> from fuel.datasets.hdf5 import H5PYDataset File "E:\Program\Anaconda2\envs\ComplexNet\lib\site-packages\fuel\datasets\hdf5.py", line 8, in <module> import tables File "E:\Program\Anaconda2\envs\ComplexNet\lib\site-packages\tables\__init__.py", line 90, in <module> from .utilsextension import (get_pytables_version, get_hdf5_version, blosc_compressor_list,blosc_compcode_to_compname_ as blosc_compcode_to_compname,blosc_get_complib_info_ as blosc_get_complib_info) ImportError: DLL load failed

tried installing with conda and pycharm.
I am working on windows10, should this be the problem?

ImportError: No module named models.complex

When I run the example code, it gives me this error, please help. Thanks.

deep_complex_networks$ train.py shallow_model --in-memory --model=shallow_convnet --local-data data/musicnet_11khz.npz
Using Theano backend.
Traceback (most recent call last):
File "/home/bowei/miniconda2/bin/train.py", line 4, in
import('pkg_resources').run_script('DeepComplexNetworks==1', 'train.py')
File "/home/bowei/.local/lib/python2.7/site-packages/pkg_resources/init.py", line 739, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/home/bowei/.local/lib/python2.7/site-packages/pkg_resources/init.py", line 1507, in run_script
exec(script_code, namespace, namespace)
File "/home/bowei/miniconda2/lib/python2.7/site-packages/DeepComplexNetworks-1-py2.7.egg/EGG-INFO/scripts/train.py", line 16, in

ImportError: No module named models.complex

Shape adding error

Hi all,

I got this error when trying to run the command: python scripts/run.py train. Same error when I tried other dataset: python scripts/run.py train --dataset cifar100. Maybe the wrong shapes of O and I since somehow the last dimension mismatches. Any idea?

File "/media/akila/5EA259B1A2598E81/Kien/deep_complex_networks/scripts/training.py", line 608, in train
model = getResnetModel(d)
File "/media/akila/5EA259B1A2598E81/Kien/deep_complex_networks/scripts/training.py", line 214, in getResnetModel
O = getResidualBlock(O, filsize, [sf2, sf2], 3, str(i+1), 'regular', convArgs, bnArgs, d)
File "/media/akila/5EA259B1A2598E81/Kien/deep_complex_networks/scripts/training.py", line 109, in getResidualBlock
O = Add()([O, I])
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 577, in call
self.build(input_shapes)
File "/usr/local/lib/python2.7/dist-packages/keras/layers/merge.py", linFile "/media/akila/5EA259B1A2598E81/Kien/deep_complex_networks/scripts/training.py", line 608, in train
model = getResnetModel(d)
File "/media/akila/5EA259B1A2598E81/Kien/deep_complex_networks/scripts/training.py", line 214, in getResnetModel
O = getResidualBlock(O, filsize, [sf2, sf2], 3, str(i+1), 'regular', convArgs, bnArgs, d)
File "/media/akila/5EA259B1A2598E81/Kien/deep_complex_networks/scripts/training.py", line 109, in getResidualBlock
O = Add()([O, I])
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 577, in call
self.build(input_shapes)
File "/usr/local/lib/python2.7/dist-packages/keras/layers/merge.py", line 84, in build
output_shape = self._compute_elemwise_op_output_shape(output_shape, shape)
File "/usr/local/lib/python2.7/dist-packages/keras/layers/merge.py", line 55, in _compute_elemwise_op_output_shape
str(shape1) + ' ' + str(shape2))
ValueError: Operands could not be broadcast together with shapes (32, 16, 44) (32, 16, 22)
e 84, in build
output_shape = self._compute_elemwise_op_output_shape(output_shape, shape)
File "/usr/local/lib/python2.7/dist-packages/keras/layers/merge.py", line 55, in _compute_elemwise_op_output_shape
str(shape1) + ' ' + str(shape2))
ValueError: Operands could not be broadcast together with shapes (32, 16, 44) (32, 16, 22)

Unknown initializer

When I finish the training, I want to reload the model from Checkpoint file, the error "Unknown initializer" occurred. How to solve the problem?
The reloading code is
selection_020

The error is
selection_019

Question concerning weight initialization.

@ChihebTrabelsi In the current implementation of ComplexInit in init.py, the scale factor uses the following.
if self.criterion == 'glorot': s = 1. / (fan_in + fan_out) elif self.criterion == 'he': s = 1. / fan_in

However, it was my understanding from the paper that the s variable is the mode for the Rayleigh distribution and this mode should be set at s = 1./sqrt(fan_in +fan_out) and s = 1./sqrt(fan_out).

Please correct me if I am wrong, but doesn't this mean that the current implementation is missing a sqrt operation for the simple complex initialization?

shallow complex model on Musicnet Dataset

Hi all,
I got this error when trying to run the command: python train.py shallow_complex_model --in-memory --model=complex_shallow_convnet --complex --local-data data/musicnet_11khz.npz
2017-10-07 20-14-06
then i change
image
then i make a change that let "channels= 2", which is " channels=feature_dim[1]=1" before. Then i pass the previous question and get another error.
image

ValueError: Error when checking target: expected complex_dense_1 to have shape (None, 48) but got array with shape (38400, 24)

I am working with the shallownet architecture for my own implementation. The backend is Theano and I am running keras 2.1.1. So far, I have the complex convolution layers working. I am now trying to get the complex dense layers working as well. The model is able to be created and the following is the summary. In the future, once this works I will have more layers and then eventually take the real part of the output and make it a one-hot vector.

_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
input_1 (InputLayer)         (None, 1024, 2)           0
_________________________________________________________________
complex_conv1d_1 (ComplexCon (None, 1024, 32)          224
_________________________________________________________________
average_pooling1d_1 (Average (None, 256, 32)           0
_________________________________________________________________
permute_1 (Permute)          (None, 32, 256)           0
_________________________________________________________________
flatten_1 (Flatten)          (None, 8192)              0
_________________________________________________________________
complex_dense_1 (ComplexDens (None, 48)                196656
=================================================================
Total params: 196,880
Trainable params: 196,880
Non-trainable params: 0
_________________________________________________________________

After the summary is printed out, the following error occurs:

starting training
saving model to ./weights/training_data_chunk_1_snrs_10.0_2018-07-06_18.34.17.wts.h5
cnn_complex.py:190: UserWarning: The `nb_epoch` argument in `fit` has been renamed `epochs`.
  outs = ComplexDense(24, activation='sigmoid',bias_initializer=Constant(value=-5))(outs)
Traceback (most recent call last):
  File "cnn_complex.py", line 190, in <module>
    outs = ComplexDense(24, activation='sigmoid',bias_initializer=Constant(value=-5))(outs)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1574, in fit
    batch_size=batch_size)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1411, in _standardize_user_data
    exception_prefix='target')
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 153, in _standardize_input_data
    str(array.shape))
ValueError: Error when checking target: expected complex_dense_1 to have shape (None, 48) but got array with shape (38400, 24)

The shape (38400, 24) is the shape of the label, i.e. 38400 is the size of the training set and 24 is the number of classes.

modReLU

Hi,

Does anyone have code for modReLU with tensorflow as a backend?

I don't see modReLU in this repo.

about complex training

image
How to solve this problem:'ValueError:Operands could not be broadcast together with shape(32,16,44)(32,16,22)?'Thanks!

Error executing with --stft

Hi,
I'm trying to run the sample experiments with MusicNet, but replacing the --fourier param with --stft:
train.py deep_model --in-memory --model=deep_convnet --local-data data/musicnet_11khz.npz --fast-load --stft

No matter which model I use, when using --stft I always get an error like this:

.. building model
.. using deep convnet
Traceback (most recent call last):
  File "./train.py", line 142, in <module>
    main(**parser.parse_args().__dict__)
  File "./train.py", line 100, in main
    model = get_model(model, dataset.feature_dim)
  File "./train.py", line 77, in get_model
    channels=feature_dim[1])
  File "/home/cperez/code/audio-transcription-complex-networks/musicnet/musicnet/models/__init__.py", line 95, in get_deep_convnet
    kernel_initializer='glorot_normal'))
  File "/home/cperez/miniconda3/envs/complex/lib/python2.7/site-packages/keras/models.py", line 455, in add
    output_tensor = layer(self.outputs[0])
  File "/home/cperez/miniconda3/envs/complex/lib/python2.7/site-packages/keras/engine/topology.py", line 528, in __call__
    self.build(input_shapes[0])
  File "/home/cperez/miniconda3/envs/complex/lib/python2.7/site-packages/keras/layers/core.py", line 827, in build
    constraint=self.kernel_constraint)
  File "/home/cperez/miniconda3/envs/complex/lib/python2.7/site-packages/keras/engine/topology.py", line 364, in add_weight
    weight = K.variable(initializer(shape), dtype=K.floatx(), name=name)
  File "/home/cperez/miniconda3/envs/complex/lib/python2.7/site-packages/keras/initializers.py", line 201, in __call__
    dtype=dtype, seed=self.seed)
  File "/home/cperez/miniconda3/envs/complex/lib/python2.7/site-packages/keras/backend/theano_backend.py", line 1987, in truncated_normal
    normal_tensor = rng.normal(size=shape, avg=mean, std=stddev, dtype=dtype)
  File "/home/cperez/miniconda3/envs/complex/lib/python2.7/site-packages/theano/sandbox/rng_mrg.py", line 1574, in normal
    nstreams=nstreams)
  File "/home/cperez/miniconda3/envs/complex/lib/python2.7/site-packages/theano/sandbox/rng_mrg.py", line 1344, in uniform
    size)
ValueError: ('The specified size contains a dimension with value <= 0', (-1572864,))

Is there something wrong in the way I'm using the script? Notice I'm using the --fast-load param, I have not tried with the full dataset yet.
Thanks!

different shape tensors

Hi,
I have tried to run:
KERAS_BACKEND=theano python scripts/run.py train
but I get bellow error, could you plz advice?
thanks,

Traceback (most recent call last):
File "scripts/run.py", line 230, in
main(sys.argv)
File "scripts/run.py", line 228, in main
return d.subcmdfn(d)
File "scripts/run.py", line 186, in run
import training;training.train(d)
File "/Users/shokoohkhandan/mygitcode/deep_complex_networks/scripts/training.py", line 609, in train
model = getResnetModel(d)
File "/Users/shokoohkhandan/mygitcode/deep_complex_networks/scripts/training.py", line 215, in getResnetModel
O = getResidualBlock(O, filsize, [sf2, sf2], 3, str(i+1), 'regular', convArgs, bnArgs, d)
File "/Users/shokoohkhandan/mygitcode/deep_complex_networks/scripts/training.py", line 110, in getResidualBlock
O = Add()([O, I])
File "/Users/shokoohkhandan/anaconda3/envs/complex/lib/python2.7/site-packages/keras/engine/topology.py", line 592, in call
self.build(input_shapes)
File "/Users/shokoohkhandan/anaconda3/envs/complex/lib/python2.7/site-packages/keras/layers/merge.py", line 90, in build
output_shape = self._compute_elemwise_op_output_shape(output_shape, shape)
File "/Users/shokoohkhandan/anaconda3/envs/complex/lib/python2.7/site-packages/keras/layers/merge.py", line 61, in _compute_elemwise_op_output_shape
str(shape1) + ' ' + str(shape2))
ValueError: Operands could not be broadcast together with shapes (32, 16, 44) (32, 16, 22)

ValueError in complex_shallow_convnet

In trying to run through the README, I encounter this error when trying to run the first complex model with scripts/train.py shallow__complex_model --in-memory --model=complex_shallow_convnet --complex --local-data data/musicnet_11khz.npz and am unsure of how to fix it.

Traceback (most recent call last):
  File "scripts/train.py", line 148, in <module>
    main(**parser.parse_args().__dict__)
  File "scripts/train.py", line 106, in main
    model = get_model(model, dataset.feature_dim)
  File "scripts/train.py", line 79, in get_model
    channels=feature_dim[1])
  File "/home/oisin/deep_complex_networks/musicnet/musicnet/models/complex/__init__.py", line 31, in get_shallow_convnet
    activation='relu')(inputs)
  File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 587, in __call__
    self.assert_input_compatibility(inputs)
  File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 497, in assert_input_compatibility
    ' but got shape ' + str(x_shape))
ValueError: Input 0 is incompatible with layer complex_conv1d_1: expected axis -1 of input shape to have value 0 but got shape (None, 4096, 1)

Any help would be greatly appreciated!

questions about transformation of tensor shape in Conv2d

Hello,I have built a Conv2d instance with num_filters=6 and kernei_size=(3,3),and the input of the conv2d layer is a tensor of [1,12,12,6] with complexed value. Shape=(batch_size, h, w, channels).
Then I found that the output of this layer is of [1,10,10,12] with real value.While the expected tensor should be [1,10,10,6] with complexed value.
Does the [1,10,10,12] tensor stand for the real part and imagenary part of output tensor?If so, we can concate the [1,10,10,:6] and [1,10,10,6:] to get the final expected tensor, right?
Thank you for reading,look forward to your reply.

Theano framework migrates to TensorFlow

Hi ChihebTrabelsi,
I would like to do further work on the basis of your work, that is, want to embed the deep complex network into DCGAN (Deep Convolutional Generative Adversarial Networks), but DCGAN is implemented with tensorflow, and your complex network is using theano as k programms, and use theano.tensor.fft module to achieve Batched 1-D FFT, Batched 1-D IFFT, Batched 2-D FFT, Batched 2-D IFFT. Now I want to migrate your code to TensorFlow framework, how to use tf.fft, tf.fft2d achieve the same function. Hope to get your help? I will be grateful, thank you!

Fourier argument question & comparison of shallow vs. deep complex models

In the readme examples, why is --fourier only used for the deep models, both real and complex, but not in either shallow model?

I think there's an error somewhere. Trying the shallow complex model both with and without --fourier both error out, but the deep complex model trains fine.

bad:
train.py shallow_complex_model --in-memory --model=complex_shallow_convnet --complex --local-data /home/data/musicnet_11khz.npz -> division by zero error
train.py shallow_complex_model --in-memory --model=complex_shallow_convnet --fourier --complex --local-data /home/data/musicnet_11khz.npz -> too many arguments error

good:
train.py deep_complex_model --in-memory --model=complex_deep_convnet --fourier --complex --local-data /home/neuro/data/musicnet_11khz.npz

Problem about ComplexBN

Hi,
I have some question about this ComplexBN class at line 409,410,

if training in {0, False}:
            return input_bn

why we don't need moving_mean and moving_variance when testing?

I also see another function at line 421,

def normalize_inference():
                if self.center:
                    inference_centred = inputs - K.reshape(self.moving_mean, broadcast_mu_shape)
                else:
                    inference_centred = inputs
                return ComplexBN(
                    inference_centred, self.moving_Vrr, self.moving_Vii,
                    self.moving_Vri, self.beta, self.gamma_rr, self.gamma_ri,
                    self.gamma_ii, self.scale, self.center, axis=self.axis
                )

When testing, this function doesn't be called. Is there any mistake?

The code below are the source code in Keras, they return "normalize_inference()" when testing.

 if training in {0, False}:
           return normalize_inference()

Thanks!

GetReal not working

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.