Skip to content

Instantly share code, notes, and snippets.

Avatar

Merishna S. Suwal merishnaSuwal

View GitHub Profile
View clean_hypothyroid_data_5.py
# Dropping the TBG column as it contains extremely high number of null values
dataset.drop('TBG', axis = 1, inplace=True)
View clean_hypothyroid_data_4.py
# Replacing ? into NaN values
dataset.replace(to_replace='?', inplace=True, value=np.NaN)
# Count the number of null values
dataset.isnull().sum()
View clean_hypothyroid_data_3.py
# Displaying the categories in different columns
print("Unique categories in the column 'pregnant'", dataset['pregnant'].unique())
print("Count of categories in the column 'pregnant' \n", dataset["pregnant"].value_counts())
print("\nUnique categories in the column 'T3 measured'", dataset['T3_measured'].unique())
print("Count of categories in the column 'T3 measured' \n", dataset["T3_measured"].value_counts())
print("\nUnique categories in the column 'Gender'", dataset['Gender'].unique())
print("Count of categories in the column 'Gender' \n", dataset["Gender"].value_counts())
View clean_hypothyroid_data_2.py
# mapping the values into binary
dataset["target"] = dataset["target"].map({"negative":0,"hypothyroid":1})
View clean_hypothyroid_data_1.py
# Renaming the first column as target
dataset = dataset.rename(columns = {dataset.columns[0]:"target"})
# Check the count of data in target
dataset["target"].value_counts()
View plot_generated_images.py
show_images = 5
# Plot the images from last epoch
data_images = helper.get_batch(glob(os.path.join("./generated_images/epoch_" + str(num_epochs-1) +"/", '*.jpg'))[:show_images], 64, 64, 'RGB')
plt.imshow(helper.images_square_grid(data_images, 'RGB'))
View hyperparameter_setting.py
# Size of latent (noise) vector to generator
z_dim = 100
# Learning ratess
learning_rate_D = .00005
learning_rate_G = 2e-4
# Batch size
batch_size = 4
# Number of epochs
View train_gan_model.py
def train_gan_model(epoch, batch_size, z_dim, learning_rate_D, learning_rate_G, beta1, get_batches, data_shape, data_image_mode, alpha):
"""
Train the GAN model.
Arguments:
----------
:param epoch: Number of epochs
:param batch_size: Batch Size
:param z_dim: Z dimension
:param learning_rate: Learning Rate
View generator_output.py
def generator_output(sess, n_images, input_z, output_channel_dim, image_mode, image_path):
"""
Save output from the generator.
Arguments:
----------
:param sess: TensorFlow session
:param n_images: Number of Images to display
:param input_z: Input Z Tensor (noise vector)
:param output_channel_dim: The number of channels in the output image
View optimizers.py
def gan_model_optimizers(d_loss, g_loss, disc_lr, gen_lr, beta1):
"""
Get optimization operations
Arguments:
----------
:param d_loss: Discriminator loss Tensor
:param g_loss: Generator loss Tensor
:param disc_lr: Placeholder for Learning Rate for discriminator
:param gen_lr: Placeholder for Learning Rate for generator