diff --git a/cgan_earth/code_files/model.py b/cgan_earth/code_files/model.py index 7601537..aaed610 100644 --- a/cgan_earth/code_files/model.py +++ b/cgan_earth/code_files/model.py @@ -6,7 +6,7 @@ def train(pth, gen, disc, imgs, labels, img_length, n_classes, num_epochs, z_dim, batch_size, lr, device, wandb_name): - rt = 1 + rt = 0 lz = 6 beta1 = 0.5 beta2 = 0.999 diff --git a/cgan_earth/code_files/networks.py b/cgan_earth/code_files/networks.py index d7c54ab..08dabac 100644 --- a/cgan_earth/code_files/networks.py +++ b/cgan_earth/code_files/networks.py @@ -8,14 +8,14 @@ def cgan_earth_nets(path, Training, g_dim, d_dim): hidden_dim = 64 if Training == True: - layers_g = [g_dim, hidden_dim*8, hidden_dim*8, hidden_dim*8, hidden_dim*8, hidden_dim*8, 3] + layers_g = [g_dim, hidden_dim*32, hidden_dim*16, hidden_dim*8, hidden_dim*8, hidden_dim*8, 3] kernel_g = [4, 4, 4, 4, 4, 3] stride_g = [2, 2, 2, 2, 2, 1] pad_g = [2, 2, 2, 2, 2, 0] - layers_d = [d_dim, hidden_dim*8, hidden_dim*8, hidden_dim*8, hidden_dim*8, hidden_dim*8, 1] + layers_d = [d_dim, hidden_dim*8, hidden_dim*8, hidden_dim*8, hidden_dim*16, hidden_dim*32, 1] kernel_d = [4, 4, 4, 4, 4, 4] stride_d = [2, 2, 2, 2, 2, 1] - pad_d = [2, 2, 2, 2, 1, 0] + pad_d = [1, 1, 1, 1, 1, 0] params = [layers_g, kernel_g, stride_g, pad_g, layers_d, kernel_d, stride_d, pad_d] with open(path + '_params.data', 'wb') as filehandle: # store the data as binary data stream @@ -35,9 +35,9 @@ def __init__(self, g_dim, img_length, im_chan=3, hidden_dim=64): self.final_conv = nn.Conv2d(hidden_dim * 8, im_chan, 3, 1, 0) # Build the neural network self.gen = nn.Sequential( - self.make_gen_block(g_dim, hidden_dim * 8), - self.make_gen_block(hidden_dim * 8, hidden_dim * 8), - self.make_gen_block(hidden_dim * 8, hidden_dim * 8), + self.make_gen_block(g_dim, hidden_dim * 32), + self.make_gen_block(hidden_dim * 32, hidden_dim * 16), + self.make_gen_block(hidden_dim * 16, hidden_dim * 8), self.make_gen_block(hidden_dim * 8, hidden_dim * 8), self.make_gen_block(hidden_dim * 8, hidden_dim * 8) ) @@ -85,12 +85,12 @@ def __init__(self, d_dim, hidden_dim=64): self.make_crit_block(d_dim, hidden_dim * 8), self.make_crit_block(hidden_dim * 8, hidden_dim * 8), self.make_crit_block(hidden_dim * 8, hidden_dim * 8), - self.make_crit_block(hidden_dim * 8, hidden_dim * 8), - self.make_crit_block(hidden_dim * 8, hidden_dim * 8, padding=1), - self.make_crit_block(hidden_dim * 8, 1, stride=1, final_layer=True), + self.make_crit_block(hidden_dim * 8, hidden_dim * 16), + self.make_crit_block(hidden_dim * 16, hidden_dim * 32), + self.make_crit_block(hidden_dim * 32, 1, stride=1, final_layer=True), ) - def make_crit_block(self, input_channels, output_channels, kernel_size=4, stride=2, padding=2, final_layer=False): + def make_crit_block(self, input_channels, output_channels, kernel_size=4, stride=2, padding=1, final_layer=False): ''' Function to return a sequence of operations corresponding to a critic block of DCGAN; a convolution, a batchnorm (except in the final layer), and an activation (except in the final layer). diff --git a/cgan_earth/run_cgan_earth.py b/cgan_earth/run_cgan_earth.py index 757ac47..ec30d0b 100644 --- a/cgan_earth/run_cgan_earth.py +++ b/cgan_earth/run_cgan_earth.py @@ -3,7 +3,7 @@ import os PATH = os.path.dirname(os.path.realpath(__file__)) -Project_name = 'earth_cylinder_t' +Project_name = 'earth_cylinder_r' Project_dir = PATH + '/trained_generators/' wandb_name = Project_name @@ -11,7 +11,7 @@ data_path = [] labels = [] -for img_path, label in zip(['forest1'], [0]): +for img_path, label in zip(['sea1'], [0]): file = PATH + '/earth_screenshots/{}.jpg'.format(img_path) data_path.append(file) # path to training data labels.append(label) @@ -21,7 +21,7 @@ # define hyperparameters and architecture ngpu = 1 z_dim = 64 -lr = 0.0001 +lr = 0.0002 Training = 1 n_classes = 1 batch_size = 2