Coder Social home page Coder Social logo

ratschlab / rgan Goto Github PK

View Code? Open in Web Editor NEW
637.0 37.0 183.0 39.69 MB

Recurrent (conditional) generative adversarial networks for generating real-valued time series data.

Home Page: https://arxiv.org/abs/1706.02633

License: MIT License

Python 100.00%
gan mnist paper medical arxiv time-series rnn

rgan's Introduction

RGAN

This repository contains code for the paper, Real-valued (Medical) Time Series Generation with Recurrent Conditional GANs, by Stephanie L. Hyland* (@corcra), Cristóbal Esteban* (@cresteban), and Gunnar Rätsch (@ratsch), from the Ratschlab, also known as the Biomedical Informatics Group at ETH Zurich.

*Contributed equally, can't decide on name ordering

Paper Overview

Idea: Use generative adversarial networks (GANs) to generate real-valued time series, for medical purposes. As the title suggests. The GAN is RGAN because it uses recurrent neural networks for both encoder and decoder (specifically LSTMs).

What does this have to do with medicine?

We aim to generate time series from ICU patients, using the open-access eICU dataset. However, we also generate some non-medical time-series, like sine waves and smooth functions sampled from Gaussian Processes, and MNIST digits (imagined as a time series).

Why generating data at all?

Sharing medical data is hard, because it comes from real people, and is naturally highly sensitive (not to mention legally protected). One workaround for this difficultly would be to create sufficiently realistic synthetic data. This synthetic data could then be used to reproducibly develop and train machine learning models, enabling better science, and ultimately better models for medicine.

When is data 'sufficiently realistic'?

We claim in this paper, that synthetic data is useful when it can be used to train a model which can perform well on real data. So, we use the performance of a classifier trained on the synthetic data, then tested on real data as a measure of the quality of the data. We call this the "TSTR score". This is a way of evaluating the output of a GAN without relying on human perceptual judgements of individual samples.

Differential privacy

We also include the case where the GAN is trained in a differentially private manner, to provide stronger privacy guarantees for the training data. We mostly just use the differentially private SGD optimiser and the moments accountant from here (with some minor modifications).

Code Quickstart

Primary dependencies: tensorflow, scipy, numpy, pandas

Note: This code is written in Python3!

Simplest route to running code (Linux/Mac):

git clone [email protected]:ratschlab/RGAN.git
cd RGAN
python experiment.py --settings_file test

Note: the test settings file is a dummy to demonstrate which options exist, and may not produce reasonable looking output.

Expected Directory Structure

See the directories in this folder: https://github.com/ratschlab/RGAN/tree/master/experiments

Files in this Repository

The main script is experiment.py - this parses many options, loads and preprocesses data as needed, trains a model, and does evaluation. It does this by calling on some helper scripts:

  • data_utils.py: utilities pertaining to data: generating toy data (e.g. sine waves, GP samples), loading MNIST and eICU data, doing test/train split, normalising data, generating synthetic data to use in TSTR experiments
  • model.py: functions for defining ML models, i.e. the tensorflow meat, defines the generator and discriminator, the update steps, and functions for sampling from the model and 'inverting' points to find their latent-space representations
  • plotting.py: visualisation scripts using matplotlib
  • mmd.py: for maximum-mean discrepancy calculations, mostly taken from https://github.com/dougalsutherland/opt-mmd

Other scripts in the repo:

  • eICU_synthetic_dataset_generation.py: essentially self-contained script for training the RCGAN to generate synthetic eICU data
  • eICU_task.py: script to help identify a doable task in eICU, and generating the training data - feel free to experiment with different, harder tasks!
  • eICU_tstr_evaluation.py: for running the TSTR evaluation using pre-generated synthetic dataset
  • eugenium_mmd.py: code for doing MMD 3-sample tests, from https://github.com/eugenium/mmd
  • eval.py: functions for evaluating the RGAN/generated data, like testing if the RGAN has memorised the training data, comparing two models, getting reconstruction errors, and generating data for visualistions of things like varying the latent dimensions, interpolating between input samples
  • mod_core_rnn_cell_impl.py: this is a modification of the same script from TensorFlow, modified to allow us to initialise the bias in the LSTM (required for saving/loading models)
  • kernel.py: some playing around with kernels on time series
  • tf_ops.py: required by eugenium_mmd.py

There are plenty of functions in many of these files that weren't used for the manuscript.

Command line options

TODO

Data sources

MNIST

Get MNIST as CSVs here: https://pjreddie.com/projects/mnist-in-csv/

eICU

eICU is access-restricted, and must be applied for. For more information: http://eicu-crd.mit.edu/about/eicu/

TODO: describe how we preprocess eICU/upload script for doing it

rgan's People

Contributors

corcra avatar cresteban avatar cristobal-est avatar goldsborough 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

rgan's Issues

test.txt file can not be found

Hello, I am trying to run experiment.py but I am getting this error:

FileNotFoundError: [Errno 2] No such file or directory: './experiments/settings/test.txt'

It seems the settings are not included.

Reproducing the eICU experiment from section 5 of the manuscript

Hi,

I'm trying to train the RGAN to reproduce your results from section 5 table 2 of the manuscript. I've got the eICU dataset, but I'm not sure of how you pre-processed/reshaped it - to be honest I'm kind of lost?

Would it be possible to share the linux command-line instructions, and the directory structure you need to run in order to get the code training - pretty please with cherries on top.

Fan Q

Generating MNIST images

I have trained a new RGAN model using MNIST data. What are the steps to generate images from the trained model?

test experiment result is correct ?

Hi,

I'm trying test experiment (sin wave).
I cannot understand the results.

This plot is generated samples through experiment.
test_epoch0099
How do I interpret this result ?

SyntaxError: future feature annotations is not defined

Hi,
I got this error, when I try to run the experiment by ''python experiment.py --setting_file test".
And this may be caused by "python<3.7".
Do you have a requirement.txt under "python>=3.7" envirment ?
Or can you tell me how to solve this problem under "python==3.6.x" envirment?

RC-GAN conditioned on Real-Input valued data (or sequence in/sequence out)?

After looking over the code it seems like the conditional part of the RC-GAN is more or less something like a one-hot vector encoded switch that can choose what signals or time-series data I want to generate from a family of distributions: See: https://github.com/ratschlab/RGAN/blob/master/model.py#L36

I am wondering if the model would still theoretically work under a sequence-to-sequence like fashion with input real values and output real values, or what is the limitation (if any) in the current implementation, that prevents this to be a natural extension.

MNIST in CSV

Hello :)

I'm a total newb? I got this error when trying to train on MNIST,

(py35_pytorch) ajay@ajay-h8-1170uk:~/PythonProjects/RGAN-master$ python experiment.py --settings_file test
Loading settings from ./experiments/settings/test.txt
Failed to load from .npy, loading from csv
Traceback (most recent call last):
  File "/home/ajay/PythonProjects/RGAN-master/data_utils.py", line 206, in mnist
    train = np.load('./data/mnist_train.npy')
  File "/home/ajay/anaconda3/envs/py35_pytorch/lib/python3.5/site-packages/numpy/lib/npyio.py", line 370, in load
    fid = open(file, "rb")
FileNotFoundError: [Errno 2] No such file or directory: './data/mnist_train.npy'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "experiment.py", line 117, in <module>
    samples, pdf, labels = data_utils.get_data(settings['data'], data_settings)
  File "/home/ajay/PythonProjects/RGAN-master/data_utils.py", line 147, in get_data
    samples, labels = load_resized_mnist_0_5(14)
  File "/home/ajay/PythonProjects/RGAN-master/data_utils.py", line 233, in load_resized_mnist_0_5
    samples, labels = mnist()
  File "/home/ajay/PythonProjects/RGAN-master/data_utils.py", line 211, in mnist
    train = np.loadtxt(open('./data/mnist_train.csv', 'r'), delimiter=',')
FileNotFoundError: [Errno 2] No such file or directory: './data/mnist_train.csv'

So I got the original MNIST data from mr lecun unzipped it, and tried to convert it to csv using this script.

Is that the right way to do it?

I though it was OK, then got this weird error?

(py35_pytorch) ajay@ajay-h8-1170uk:~/PythonProjects/RGAN-master$ python experiment.py --settings_file test
Loading settings from ./experiments/settings/test.txt
Loaded mnist from .npy
Resizing...
Generated/loaded 36017 samples from data-type mnist
Splitting labels...
False 	 WGAN_clip
100 	 hidden_units_g
14 	 num_signals
False 	 normalise
True 	 learn_scale
0.1 	 amplitude_low
0.9 	 amplitude_high
5.0 	 freq_high
True 	 shuffle
mnist 	 data
False 	 batch_mean
False 	 full_mnist
1.0 	 freq_low
False 	 wrong_labels
5 	 D_rounds
28 	 batch_size
14 	 num_generated_features
True 	 multivariate_mnist
True 	 one_hot
36017 	 num_samples
 	 data_load_from
0.1 	 scale
14 	 seq_length
0.1 	 learning_rate
False 	 predict_labels
False 	 WGAN
100 	 num_epochs
1 	 max_val
1 	 kappa
False 	 use_time
5 	 latent_dim
100 	 hidden_units_d
15 	 resample_rate_in_min
test 	 identifier
 	 settings_file
1 	 G_rounds
6 	 cond_dim
Saved training data to ./experiments/data/test.data.npy
Traceback (most recent call last):
  File "experiment.py", line 197, in <module>
    D_loss, G_loss = model.GAN_loss(Z, X, generator_settings, discriminator_settings, kappa, CGAN, CG, CD, CS, wrong_labels=wrong_labels)
  File "/home/ajay/PythonProjects/RGAN-master/model.py", line 153, in GAN_loss
    D_fake, D_logit_fake = discriminator(G_sample, reuse=True, **discriminator_settings, c=CG)
  File "/home/ajay/PythonProjects/RGAN-master/model.py", line 290, in discriminator
    inputs=x)
  File "/home/ajay/anaconda3/envs/py35_pytorch/lib/python3.5/site-packages/tensorflow/python/ops/rnn.py", line 553, in dynamic_rnn
    dtype=dtype)
  File "/home/ajay/anaconda3/envs/py35_pytorch/lib/python3.5/site-packages/tensorflow/python/ops/rnn.py", line 720, in _dynamic_rnn_loop
    swap_memory=swap_memory)
  File "/home/ajay/anaconda3/envs/py35_pytorch/lib/python3.5/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2623, in while_loop
    result = context.BuildLoop(cond, body, loop_vars, shape_invariants)
  File "/home/ajay/anaconda3/envs/py35_pytorch/lib/python3.5/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2456, in BuildLoop
    pred, body, original_loop_vars, loop_vars, shape_invariants)
  File "/home/ajay/anaconda3/envs/py35_pytorch/lib/python3.5/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2406, in _BuildLoop
    body_result = body(*packed_vars_for_body)
  File "/home/ajay/anaconda3/envs/py35_pytorch/lib/python3.5/site-packages/tensorflow/python/ops/rnn.py", line 705, in _time_step
    (output, new_state) = call_cell()
  File "/home/ajay/anaconda3/envs/py35_pytorch/lib/python3.5/site-packages/tensorflow/python/ops/rnn.py", line 691, in <lambda>
    call_cell = lambda: cell(input_t, state)
  File "/home/ajay/anaconda3/envs/py35_pytorch/lib/python3.5/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py", line 398, in __call__
    reuse=self._reuse) as unit_scope:
  File "/home/ajay/anaconda3/envs/py35_pytorch/lib/python3.5/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/home/ajay/anaconda3/envs/py35_pytorch/lib/python3.5/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py", line 93, in _checked_scope
    "the argument reuse=True." % (scope_name, type(cell).__name__))
ValueError: Attempt to have a second RNNCell use the weights of a variable scope that already has weights: 'discriminator/rnn/lstm_cell'; and the cell was not constructed as LSTMCell(..., reuse=True).  To share the weights of an RNNCell, simply reuse it in your second calculation, or create a new one with the argument reuse=True.

I also get the same error when I try to use sine wave data, i.e. try to run

python experiment.py --data sine

My Experience with the MNIST Data Set with Some Questions

I thought I'd share my experience with the MNIST data set and maybe ask some questions along the way. I used the csv version of MNIST. One of the first things I noticed was a problem with the labels. You might be able to train the model with the default settings, but in my case it did not process the labels correctly. So I found one way to fix this is to edit the mnistfull.txt settings file at experiments/settings/mnistfull.txt by changing the value of one_hot to true.

Next you copy your MNIST csv file to experiments/data/ directory. You also have to edit the code a little. Please note that since I did change the code in some of the files, the line numbers might not reflect the github archive. In any case, in line 16 of data_utils.py you want to comment out the imresize import because it is deprecated and not used for these settings. Like so:
#from scipy.misc import imresize
Next you have to fix some paths also in data_utils.py:
Line 303:
train = np.loadtxt(open('./experiments/data/mnist_train.csv', 'r'), delimiter=',')
and line 308:
np.save('./experiments/data/mnist_train.npy', train)

Now something happens when you activate one_hot that detects the 10 labels corresponding to the 10 digits. However, experiments.py is set up to only read 6 or 3 labels. This will be the cond_dim settings variable. You don't have to set it in the settings file because it will automatically write it as 10 when you set one_hot to true. I'm not sure where it does this and it is worth further investigation. Suffice it to say you have to add some code to experiment.py at around line 103. You have to add another elif statement like so:

elif cond_dim == 10:
    vis_C[:10] = np.eye(10) 

I was also having memory issues so I turned off mmd calculations according to this comment:
#16 (comment)

Finally, you have to fix your print statements. The formatting expects a numerical value for mmd and that_np so look for a try/except block at around line 260 or so (in the archive it's at line 255). Before it you have to check to make sure that_np is initialized with the following code before the try:

try: that_np
  except NameError: that_np = None

Yes, that is you add another try before the try block with the print statements. Then you change the except print statement to the following:
print('%d\t%.2f\t%.4f\t%.4f\t%s\t%s\t %s\t %s' % (epoch, t, D_loss_curr, G_loss_curr, mmd2, that_np, pdf_sample, pdf_real))
Basically, just making sure mmd2, that_np, along with pdf_sample and pdf_real are all formatted as strings.

At this point, the model trained and I went for 500 epochs.
Next, you want to generate some if not all of the digits. To do this, I did a couple of things first. In model.py, line 343, I change that line to this:
model_parameters = np.load(load_path, allow_pickle=True).item()
You have to allow_pickle or the parameters stores as npy files will not load.
Next, I wrote a script like so:

import numpy as np
import tensorflow as tf
import pdb
import random
import json
from scipy.stats import mode

import data_utils
import plotting
import model
import utils
import eval

from time import time
from math import floor
from mmd import rbf_mmd2, median_pairwise_distance, mix_rbf_mmd2_and_ratio

print("All imports worked")


tf.logging.set_verbosity(tf.logging.ERROR)

# parse command line arguments, or use defaults
parser = utils.rgan_options_parser()
settings = vars(parser.parse_args())
# if a settings file is specified, it overrides command line arguments/defaults
if settings['settings_file']: settings = utils.load_settings_from_file(settings)
print('Ready to run with settings:')

epoch = 450
num_samples = 10
idx="Test"
seq_length=settings["seq_length"]
labs = np.array([0,1,2,3,4,5,6,7,8,9])

csamples = np.zeros((10,10))

csamples[0][0] = 1
csamples[1][1] = 1
csamples[2][2] = 1
csamples[3][3] = 1
csamples[4][4] = 1
csamples[5][5] = 1
csamples[6][6] = 1
csamples[7][7] = 1
csamples[8][8] = 1
csamples[9][9] = 1

print(csamples)

synth_data = model.sample_trained_model(settings, epoch, num_samples, C_samples=csamples)
plotting.save_mnist_plot_sample(synth_data.reshape(-1, seq_length**2, 1), idx,"epoch450", num_samples, labels=labs)

You run this script just like you run experiment.py as such:
python script.py --settings_file mnistfull
Also, you probably don't need all the import statements. I just copy/pasted from experiment.py.
Basically, your C_samples are the labels you input to the generator to tell it what digits to print. In this case, we are printing all ten digits. However they are formatted as a 10x10 numpy array each row being a digit with each column index indicating which digit it is by setting it to one. So for example if you want to print zero as the first digit, you set row zero column zero to one. If you want to print the third digit as 5 you set row three column five to one. In this case, I set every digit in order so 0,0 is 0, 1,1 is 1 and so on.
Here is an example of my output:
epoch450_epochTest

Now the minimum number of digits you can print is four based on how the plotting.py script is written. But you can print out any digit. Say you wanted to print out the digits 5309. You would use the same script as above but change the num_samples variable to 4. Create the csamples array with a shape of (4,10) and construct the array as:

csamples[0][5] = 1
csamples[1][3] = 1
csamples[2][0] = 1
csamples[3][9] = 1

Your output might look like this:
5309e450_epochTest

Note this is after 450 epochs.
Well this was my experience with MNIST and this algorithm. Hopefully this will help someone along the way. I am also not clear from a theory perspective what the one_hot value does. Hopefully, I am not invalidating the results by the changes I made to the code.
Thank you.

What are the 7 Lables of the eICU dataset experiment from section 5 of the manuscript

hi,
I am going to use do the eICU dataset experiment from section 5 of the manuscript.As i have not got the eICU dataset , i don't know 7 labels in your code. So,could you show me the details of those 7 lables.
By the way , could you offer a brief introduction about the eICUdataset in your manuscript?
Thank s a lot.

Generator and Discriminator losses changes after some time

Hi! I am using RGAN; the training is successfully going on with my dataset. It is also generating good samples but after some epochs, the generator loss is again increasing and has noisy samples. Again after some epochs, it produces good results. I do know why! Can anyone help me?

Use of D_wrong?

hi @corcra
May I ask what is D_wrong for? It seems like that it together with variables CS, D_logit_wrong are defined but have not been used?
And are CG and CG always the same? Should these two merge ? I think it is reasonable that generator and discriminator share the same condition.
Thanks for your great work!

Discriminator cond_dim if statement being bypassed

This is just a heads up to the authors or anyone who is using conditional inputs, but in the current state of things this if statement is being ignored.
model.py line 275

    if cond_dim > 0:
        assert not c is None
        repeated_encoding = tf.stack([c]*seq_length, axis=1)
        inputs = tf.concat([x, repeated_encoding], axis=2)
    else:
        inputs = x

As at model.py line 292, inputs is set to x, rather than being set to inputs.

    rnn_outputs, rnn_states = tf.nn.dynamic_rnn(
        cell=cell,
        dtype=tf.float32,
        inputs=x)

Making this small change allowed me to finally train my first conditional model.

Error running experiment.py

Hello, I am trying to run experiment.py but I am getting this error:

Traceback (most recent call last): File "experiment.py", line 9, in <module> import data_utils File "RGAN/data_utils.py", line 9, in <module> import model File "RGAN/model.py", line 7, in <module> from mod_core_rnn_cell_impl import LSTMCell #modified to allow initializing bias in lstm File "RGAN/mod_core_rnn_cell_impl.py", line 45, in <module> from tensorflow.python.ops.rnn_cell_impl import _RNNCell as RNNCell ImportError: cannot import name '_RNNCell'

Improper scaling

I believe your scale_data() is scaling horizontally across the signals rather than down the time series for each of signal itself. I used:

def scale_linear_bycolumn(rawpoints, high=1.0, low=-1.0):
mins = np.min(rawpoints, axis=0)
maxs = np.max(rawpoints, axis=0)
rng = maxs - mins
return high - (((high - low) * (maxs - rawpoints)) / rng)

I think it would make sense to scale the whole signals's timeseries (down the column) rather than across at each time step. I noticed this when I was inputing signals with different amplitudes and the values starting to fill as NaN because it was being scaled across signals at a timestep rather than down the signal to all the values for that signal's time series.

Plotting.py documentation

Hi guys!
Is it possible for you to add some more detailed documentation on the plotting.py file?
Also i wanted to ask if i just wanted to recreate your experiment with the mnist dataset,
which of the functions in plotting.py would be used to help visualize the results just for the mnist experiment? Thank you.

TypeError: must be real number, not str

Traceback (most recent call last):
File "experiment.py", line 258, in
print('%d\t%.2f\t%.4f\t%.4f\t%.5f\t%.0f\t %s\t %s' % (epoch, t, D_loss_curr, G_loss_curr, mmd2, that_np, pdf_sample, pdf_real))
TypeError: must be real number, not str

I am getting this error while running experiment.py on my data with "num_samples": 869,
"seq_length": 300,
"num_signals": 9.

test.trace.txt ?

Thanks for the great job!
However when i run the code i got error message:

FileNotFoundError: [Errno 2] No such file or directory: './experiments/traces/test.trace.txt'
so where is the test.trace.txt ?

MNIST Generator

I clone the code and download the mnist in csv, run python experiment.py --settings_file mnistfull.
Almost all images generated in experiments/plot are digit as '1' after 250 epoches which seems like mode collapse . Is it a common phenomenon? Or how to avoid it?

README.md file?

Was curious if there is a README file. The code looks very well commented, but not really sure where to start looking, or where the main function is!

Sample_C ?

I want to understand what's the role of this function in the code. Thanks

Generating new data from parameters saved in eICU_synthetic_dataset_generation.py

Hello @corcra ! I have run 'eICU_synthetic_dataset_generation' on my own data and it's generating pretty good results, while it is getting trained. But I am confused about generating new data after training from the saved parameters. The name of the values in parameters are also very different from parameters saved by running experiment.py. Is there ant code available to generate data from parameters saved while running 'eICU_synthetic_dataset_generation' ?

Trying to implement RGAN in MXNet Gluon

Hello everybody,
I am currently trying to convert RGAN to MXNet Gluon.
But I still cannot reproduce the results. So I think there are some issues in my code.

Some parts of the Tensorflow code are still confusing for me. It would be very helpful if you can answer some of my questions.

In the generator line 278 we have :
logits_2d = tf.matmul(rnn_outputs_2d, W_out_G) + b_out_G
and in the discriminator line 317 we have :
logits = tf.einsum('ijk,km', rnn_outputs, W_out_D) + b_out_D

I understand that you are doing a weighted sum and reducing dimensions, but what is the difference between matmul and einsum in this case ?
Are W_out/b_out static tensors ? Or are they evolving during the training phase ?
Can we replace these operations by Dense/Linear layers, they are able to reduce dims after all

Thank you

Pytorch version

Hi, thank you for your codes. And I wonder whether there is a pytorch version of the codes?

NameError: name 'clip_disc_weights' is not defined

Hi,
When I change the setting file to enable WGAN and WGAN_clip and run the model, it gives the Error:
NameError: name 'clip_disc_weights' is not defined
Should I give clip_disc_weights a value that constraint the weight value of the network?

Thanks !!

Memory requirements

Hello, I am attempting to run this code:

python3 experiment.py --settings_file test

But I am running out of memory (OOM error):

2017-12-09 23:17:18.540786: W tensorflow/core/common_runtime/bfc_allocator.cc:277] ***************************************************************************************************x
2017-12-09 23:17:18.540796: W tensorflow/core/framework/op_kernel.cc:1192] Resource exhausted: OOM when allocating tensor with shape[3988,3988]
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1323, in _do_call
    return fn(*args)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1302, in _run_fn
    status, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/errors_impl.py", line 473, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[3988,3988]
	 [[Node: mul_790 = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"](Neg_102, add_467)]]
	 [[Node: truediv_233/_165 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_216_truediv_233", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "experiment.py", line 221, in <module>
    mmd2, that_np = sess.run(mix_rbf_mmd2_and_ratio(eval_test_real, eval_test_sample,biased=False, sigmas=sigma))
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 889, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1120, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1317, in _do_run
    options, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1336, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[3988,3988]
	 [[Node: mul_790 = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"](Neg_102, add_467)]]
	 [[Node: truediv_233/_165 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_216_truediv_233", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

Caused by op 'mul_790', defined at:
  File "experiment.py", line 221, in <module>
    mmd2, that_np = sess.run(mix_rbf_mmd2_and_ratio(eval_test_real, eval_test_sample,biased=False, sigmas=sigma))
  File "/home/jchook/dev/RGAN/mmd.py", line 71, in mix_rbf_mmd2_and_ratio
    K_XX, K_XY, K_YY, d = _mix_rbf_kernel(X, Y, sigmas, wts)
  File "/home/jchook/dev/RGAN/mmd.py", line 52, in _mix_rbf_kernel
    K_YY += wt * tf.exp(-gamma * (-2 * YY + c(Y_sqnorms) + r(Y_sqnorms)))
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/math_ops.py", line 894, in binary_op_wrapper
    return func(x, y, name=name)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/math_ops.py", line 1117, in _mul_dispatch
    return gen_math_ops._mul(x, y, name=name)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/gen_math_ops.py", line 2726, in _mul
    "Mul", x=x, y=y, name=name)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 2956, in create_op
    op_def=op_def)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 1470, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[3988,3988]
	 [[Node: mul_790 = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"](Neg_102, add_467)]]
	 [[Node: truediv_233/_165 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_216_truediv_233", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

What are the minimum GPU memory requirements?

Tensorflow version compatilibty?

Was curious what tensorflow version this was compiled in. I have all packaged for python3, and now I'm getting an error message whenI run the sample code in the README.md regarding the test file:

from tensorflow.python.ops.rnn_cell_impl import _RNNCell as RNNCell # Original Implementation
ImportError: cannot import name '_RNNCell'

*Traces this to the mod_core_rnn_cell_impl.py file. This was ran on tensorflow 1.2.1

Reproducing the results of the RGAN on the eICU data

Hi,

I'm trying to train the RGAN to reproduce your results on the eICU data. I've got the eICU dataset, but I'm not sure of how you pre-processed/reshaped it?

Would it be possible to share the script for preprocessing eICU data? perhaps also the linux command-line instructions, and the directory structure you need to run in order to get the code training on the data? Also, I tried following your instructions you gave on a similar previous issue about converting the files to hdf5, and I ran into memory errors when I try to do that using the simple to_hdf pandas API. Is there some other more efficient way to do that?

Thank you!

Other Time series data

Can it be used with any time series data. Can iy be used in financial markets What's the format of data it accepts like.. csv and no of example of sample data. Where I find the sample data which is used here.

Why are the outputs of discriminator not 0/1-value?

HI, guys,
Thanks for your great job!

When I go though your code, I notice that the output of discriminator seemed not to be 0/1 but a 0/1 - matrix? Why is that ? Is it heuristic way?
Thanks a lot.

# from line 316 model.py line 
#      logit_final = tf.matmul(rnn_outputs[:, -1], W_final_D) + b_final_D
        logits = tf.einsum('ijk,km', rnn_outputs, W_out_D) + b_out_D
#      rnn_outputs_flat = tf.reshape(rnn_outputs, [-1, hidden_units_d])
#      logits = tf.matmul(rnn_outputs_flat, W_out_D) + b_out_D

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.