Skip to content

Commit

Permalink
sync remote changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeng committed Sep 14, 2021
1 parent 660849b commit 9ea57ba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cgan_earth/code_files/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions cgan_earth/code_files/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
)
Expand Down Expand Up @@ -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).
Expand Down
6 changes: 3 additions & 3 deletions cgan_earth/run_cgan_earth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
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

# import training images and define labels
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)
Expand All @@ -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
Expand Down

0 comments on commit 9ea57ba

Please sign in to comment.