From 1a091338d2143aa30c777356c6640e64e15badcd Mon Sep 17 00:00:00 2001 From: Reynaldo Morillo Date: Fri, 15 Dec 2017 16:44:39 -0500 Subject: [PATCH] Just fixed the problem. I commented out the matplotlib because I'm using a virtual environment and it has problems with that. Otherwise, the more concerning problem of the dimension was resolved by defining the correct definitino of the input and out of the generative model and the input of the discriminator model. I use defining the input as 2-D matrix instead of 1-D vector by accident. It turns out (R, 1) and (R,) mean different things! Where the former is a 2-D matrix, and later is a 1-D vector. Super thanks to this help of understanding the shape system in Numpy (https://stackoverflow.com/questions/22053050/difference-between-numpy-array-shape-r-1-and-r) --- gan/gan.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gan/gan.py b/gan/gan.py index 72bbee0..f1788dd 100644 --- a/gan/gan.py +++ b/gan/gan.py @@ -4,7 +4,7 @@ import os import numpy as np import pandas as pd from sklearn.cross_validation import train_test_split -import matplotlib.pyplot as plt +# import matplotlib.pyplot as plt # Nuerual Net Building from keras import layers from keras.layers import Input, Dense, Dropout, InputLayer, Reshape @@ -45,8 +45,8 @@ x_train = all_data.iloc[:, np.arange(20)] # Data Variables input_dimension = x_train.shape[1] # Number of features (e.g. genes) -gen_input_shape = (1, input_dimension) -discr_input_shape = (1, input_dimension) +gen_input_shape = (input_dimension,) +discr_input_shape = (input_dimension,) epochs = 10 batch_size = x_train.shape[0] @@ -95,7 +95,7 @@ training_record = model.fit(x=x_train, y=gan_targets(x_train.shape[0]), epochs=e # Predict (i.e. produce new samples) zsamples = np.random.normal(size=(1, input_dimension)) -pred = generator.predict(zsamples) +pred = generative_model.predict(zsamples) print(pred) # Save new samples to file