greenelab / tybalt

Training and evaluating a variational autoencoder for pan-cancer gene expression data
BSD 3-Clause "New" or "Revised" License
162 stars 61 forks source link

Keras versioning error #106

Closed ajlee21 closed 6 years ago

ajlee21 commented 6 years ago

Error using Keras version 2.1.3 and tensorflow version 1.5.0

https://github.com/gwaygenomics/tybalt/blob/84c6079f98ac4aa9269eead0afbd424369a94d20/scripts/vae_pancancer.py#L163

gwaybio commented 6 years ago

Thanks @ajlee21 - if possible, can you post the error here?

Tybalt currently uses Keras 2.0.6 and tensorflow 1.0.1 but its probably time for an update and for this to be fixed.

ajlee21 commented 6 years ago

Using TensorFlow backend. /home/alexandra/anaconda2/envs/python3/lib/python3.6/site-packages/ipykernel_launcher.py:135: UserWarning: Output "custom_variational_layer_1" missing from loss dictionary. We assume this was done on purpose, and we will not be expecting any data to be passed to "custom_variational_layer_1" during training.


ValueError Traceback (most recent call last)

in () 139 hist = vae.fit(np.array(rnaseq_train_df), shuffle=True, epochs=epochs, batch_size=batch_size, 140 validation_data=(np.array(rnaseq_test_df), np.array(rnaseq_test_df)), --> 141 callbacks=[WarmUpCallback(beta, kappa)]) 142 143 # Save training performance ~/anaconda2/envs/python3/lib/python3.6/site-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs) 1612 sample_weight=val_sample_weight, 1613 check_batch_axis=False, -> 1614 batch_size=batch_size) 1615 if self.uses_learning_phase and not isinstance(K.learning_phase(), int): 1616 val_ins = val_x + val_y + val_sample_weights + [0.] ~/anaconda2/envs/python3/lib/python3.6/site-packages/keras/engine/training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_batch_axis, batch_size) 1428 output_shapes, 1429 check_batch_axis=False, -> 1430 exception_prefix='target') 1431 sample_weights = _standardize_sample_weights(sample_weight, 1432 self._feed_output_names) ~/anaconda2/envs/python3/lib/python3.6/site-packages/keras/engine/training.py in _standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix) 53 raise ValueError('Error when checking model ' + 54 exception_prefix + ': ' ---> 55 'expected no data, but got:', data) 56 return [] 57 if data is None: ValueError: ('Error when checking model target: expected no data, but got:', array([[5.000000e+00, 2.440000e+02, 4.000000e+00, ..., 1.486718e+06, 7.000000e+00, 6.000000e+00], [0.000000e+00, 2.880000e+02, 0.000000e+00, ..., 3.668960e+05, 0.000000e+00, 2.000000e+00], [7.000000e+00, 1.620000e+02, 4.000000e+00, ..., 6.256400e+05, 3.000000e+00, 2.000000e+00], ..., [1.300000e+01, 3.045000e+03, 6.000000e+00, ..., 5.851519e+06, 4.100000e+01, 4.800000e+01], [7.000000e+00, 5.060000e+02, 2.000000e+00, ..., 1.172282e+06, 2.000000e+00, 6.000000e+00], [2.000000e+00, 6.970000e+02, 1.000000e+00, ..., 3.982010e+05, 1.000000e+00, 0.000000e+00]]))
gwaybio commented 6 years ago

It looks like Keras 2.1.3 (source) expects the argument to be:

validation_data=(x_array, None)

# instead of the previously required
validation_data=(x_array, x_array)

I saw this solution in keras-team/keras#7856

I can confirm this works in fitting Tybalt

print(keras.__version__)
tf.__version__
2.1.3
'1.4.1'