def logging_loop(self, it): """ Logging and checkpointing stuff """ if it % self.args.validate_every == 0: self.mapper.eval() self.navigator.eval() loss_val_seen = self.validate("val_seen") loss_val_unseen = self.validate("val_unseen") self.prev_time, time_taken = utils.time_it(self.prev_time) print("Iteration: %d Loss: %f Val Seen Loss: %f Val Unseen Loss: %f Time: %0.2f secs" %(it, self.loss.item(), loss_val_seen.item(), loss_val_unseen.item(), time_taken)) if self.visdom: # visdom: X, Y, key, line_name, x_label, y_label, fig_title self.visdom.line(it, self.loss.item(), "train_loss", "Train Loss", "Iterations", "Loss", title=" Train Phase") self.visdom.line(it, loss_val_seen.item(), "val_loss", "Val Seen Loss", "Iterations", "Loss", title="Val Phase") self.visdom.line(it, loss_val_unseen.item(), "val_loss", "Val Unseen Loss", "Iterations", "Loss", title="Val Phase") self.mapper.train() self.navigator.train() elif it % self.args.log_every == 0: self.prev_time, time_taken = utils.time_it(self.prev_time) print("Iteration: %d Loss: %f Time: %0.2f secs" % (it, self.loss.item(), time_taken)) if self.visdom: self.visdom.line(it, self.loss.item(), "train_loss", "Train Loss", "Iterations", "Loss", title="Train Phase") if it % self.args.checkpoint_every == 0: saver = {"mapper": self.mapper.state_dict(), "navigator": self.navigator.state_dict(), "args": self.args} dir = "%s/%s" % (self.args.snapshot_dir, self.args.exp_name) if not os.path.exists(dir): os.makedirs(dir) torch.save( saver, "%s/%s_%d" % (dir, self.args.exp_name, it) ) if self.visdom: self.visdom.save()
def __init__(self, args): super(PanoSimulator, self).__init__() self.args = args if self.args.preloading: print("Simulator images will be preloaded") prev_time = time.time() self.setPreloadingEnabled(self.args.preloading) self.setDepthEnabled(True) self.setRestrictedNavigation(False) self.setBatchSize(self.args.batch_size) self.setCacheSize(self.args.cache_size) self.setCameraResolution(self.args.image_width, self.args.image_height) self.setCameraVFOV(self.args.vfov) self.initialize() self._reset_visited_goal() prev_time, time_taken = utils.time_it(prev_time) print("Simulator initialized: %0.2f secs" % time_taken)
# 1. Combine multi line messages # 4. Map phone numbers to users # 2. Extract emojis # 5. Sentiment analysis # FILES AND LOCATIONS # of images, videos, voicemessages and locations # GIF omitted # image omitted # video omitted # audio omitted # Contact card omitted # Location: https://maps.google.com/?q=-13.523442,-71.950256 # TIMESPAN: how long did the chat go # TIMELINE: when and how much you where messaging # TOTAL NUMBERS days you are chatting, message/word/letter count # TOPS most active day if __name__ == "__main__": with time_it('Reading'): with open('_chat.txt', 'r') as f: chat = f.readlines() with open('numbers.json', 'r') as f: user_number_map = json.load(f) with time_it('Parsing'): grouped_messages = Message.parse_chat(chat, user_number_map) with time_it('Stats'): stats = compute_stats(grouped_messages) pprint(stats)
shuffle=(train_sampler is None), num_workers=n_workers, pin_memory=True, sampler=train_sampler) val_loader = torch.utils.data.DataLoader(datasets.ImageFolder( valdir, transforms.Compose([ transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), normalize, ])), batch_size=batch_size, shuffle=False, num_workers=n_workers, pin_memory=True) return train_loader, val_loader if __name__ == "__main__": # a, b = get_future_bar_classification_data(16) # test_dataset_for_loop() from utils import time_it time_it(test_dataset_for_loop # test_dataset_loader # get_cifar_10, 10, shuffle=True )
def logging_loop(self, it): """ Logging and checkpointing stuff """ if it % self.args.validate_every == 0: self.mapper.eval() self.model.eval() self.policy.eval() scores_train = self.validate("train") scores_val_seen = self.validate("val_seen") scores_val_unseen = self.validate("val_unseen") self.prev_time, time_taken = utils.time_it(self.prev_time) print( "Iteration: %d Loss: %f Train Success: %f Val Seen Success: %f Val Unseen Success: %f Time: %0.2f secs" % (it, self.loss.item(), scores_train['success'], scores_val_seen['success'], scores_val_unseen['success'], time_taken)) if self.visdom: # visdom: X, Y, key, line_name, x_label, y_label, fig_title self.visdom.line(it, self.loss.item(), "train_loss", "Train Loss", "Iterations", "Loss", title=" Train Phase") units = { 'length': 'm', 'error': 'm', 'oracle success': '%', 'success': '%', 'spl': '%' } sub = self.args.validation_iterations * self.args.batch_size for metric, score in scores_train.items(): m = metric.title() self.visdom.line(it, score, metric, "Train (%d)" % sub, "Iterations", units[metric], title=m) for metric, score in scores_val_seen.items(): m = metric.title() self.visdom.line(it, score, metric, "Val Seen (%d)" % sub, "Iterations", units[metric], title=m) for metric, score in scores_val_unseen.items(): m = metric.title() self.visdom.line(it, score, metric, "Val Unseen (%d)" % sub, "Iterations", units[metric], title=m) self.mapper.train() self.model.train() self.policy.train() elif it % self.args.log_every == 0: self.prev_time, time_taken = utils.time_it(self.prev_time) print("Iteration: %d Loss: %f Time: %0.2f secs" % (it, self.loss.item(), time_taken)) if self.visdom: self.visdom.line(it, self.loss.item(), "train_loss", "Train Loss", "Iterations", "Loss", title="Train Phase") if it % self.args.checkpoint_every == 0: saver = { "mapper": self.mapper.state_dict(), "args": self.args, "filter": self.model.state_dict(), "policy": self.policy.state_dict() } dir = "%s/%s" % (self.args.snapshot_dir, self.args.exp_name) if not os.path.exists(dir): os.makedirs(dir) torch.save(saver, "%s/%s_%d" % (dir, self.args.exp_name, it)) if self.visdom: self.visdom.save()