From 333bacd26376250d8606d737f01361853527f451 Mon Sep 17 00:00:00 2001 From: Jordan Gong Date: Tue, 12 Jan 2021 23:16:55 +0800 Subject: Bug fixes 1. Replace inplace Leaky ReLU in auto-encoder classifier with non-inplace one 2. Replace rank number with get_ordinal method in xmp --- models/auto_encoder.py | 2 +- models/model.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'models') diff --git a/models/auto_encoder.py b/models/auto_encoder.py index 64c52e3..0c247f1 100644 --- a/models/auto_encoder.py +++ b/models/auto_encoder.py @@ -126,7 +126,7 @@ class AutoEncoder(nn.Module): f_c_dim = embedding_dims[1] self.classifier = nn.Sequential( - nn.LeakyReLU(0.2, inplace=True), + nn.LeakyReLU(0.2), BasicLinear(f_c_dim, num_class) ) diff --git a/models/model.py b/models/model.py index b86a050..689fc70 100644 --- a/models/model.py +++ b/models/model.py @@ -129,14 +129,12 @@ class Model: para_loader = pl.ParallelLoader(dataloader, [device]) self._train_loop( - rank, para_loader.per_device_loader(device), rgb_pn, optimizer, scheduler, writer ) def _train_loop( self, - rank: int, dataloader: pl.PerDeviceLoader, rgb_pn: RGBPartNet, optimizer: optim.Adam, @@ -170,10 +168,10 @@ class Model: # Write losses to TensorBoard writer.add_scalar( - f'[xla:{rank}]Loss/all', loss.item(), iter_i + 1 + f'[xla:{xm.get_ordinal()}]Loss/all', loss.item(), iter_i + 1 ) writer.add_scalars( - f'[xla:{rank}]Loss/details', dict(zip([ + f'[xla:{xm.get_ordinal()}]Loss/details', dict(zip([ 'Cross reconstruction loss', 'Pose similarity loss', 'Canonical consistency loss', 'Batch All triplet loss' ], metrics)), @@ -181,7 +179,7 @@ class Model: ) if iter_i % 100 == 99: - print('[xla:{0}]({1:5d})'.format(rank, iter_i + 1), + print('[xla:{0}]({1:5d})'.format(xm.get_ordinal(), iter_i + 1), 'loss: {:6.3f}'.format(loss), '(xrecon = {:f}, pose_sim = {:f},' ' cano_cons = {:f}, ba_trip = {:f})'.format(*metrics), -- cgit v1.2.3