Compare commits

..
2 Commits
2 changed files with 9 additions and 8 deletions
@@ -314,10 +314,8 @@ class Unet(nn.Module):
default_out_dim = channels * (1 if not learned_variance else 2)
self.out_dim = default(out_dim, default_out_dim)
self.final_conv = nn.Sequential(
block_klass(dim * 2, dim),
nn.Conv2d(dim, self.out_dim, 1)
)
self.final_res_block = block_klass(dim * 2, dim, time_emb_dim = time_dim)
self.final_conv = nn.Conv2d(dim, self.out_dim, 1)
def forward(self, x, time):
x = self.init_conv(x)
@@ -346,6 +344,8 @@ class Unet(nn.Module):
x = upsample(x)
x = torch.cat((x, r), dim = 1)
x = self.final_res_block(x, t)
return self.final_conv(x)
# gaussian diffusion trainer class
@@ -597,7 +597,6 @@ class Trainer(object):
folder,
*,
ema_decay = 0.995,
image_size = 128,
train_batch_size = 32,
train_lr = 1e-4,
train_num_steps = 100000,
@@ -610,6 +609,8 @@ class Trainer(object):
augment_horizontal_flip = True
):
super().__init__()
self.image_size = diffusion_model.image_size
self.model = diffusion_model
self.ema = EMA(ema_decay)
self.ema_model = copy.deepcopy(self.model)
@@ -623,9 +624,9 @@ class Trainer(object):
self.gradient_accumulate_every = gradient_accumulate_every
self.train_num_steps = train_num_steps
self.ds = Dataset(folder, image_size, augment_horizontal_flip = augment_horizontal_flip)
self.ds = Dataset(folder, self.image_size, augment_horizontal_flip = augment_horizontal_flip)
self.dl = cycle(data.DataLoader(self.ds, batch_size = train_batch_size, shuffle = True, pin_memory = True, num_workers = cpu_count()))
self.opt = Adam(diffusion_model.parameters(), lr=train_lr)
self.opt = Adam(diffusion_model.parameters(), lr = train_lr)
self.step = 0
+1 -1
View File
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
setup(
name = 'denoising-diffusion-pytorch',
packages = find_packages(),
version = '0.20.0',
version = '0.20.2',
license='MIT',
description = 'Denoising Diffusion Probabilistic Models - Pytorch',
author = 'Phil Wang',