def test_load_net_should_load_known_net_types(self): files = ["test.adjlist", "test.gml", "test.edgelist"] for name in files: try: g = nets.load_net(os.path.join(test_net_path, name)) except Exception, e: raise Exception("'%s' failed to parse: %s" % (name, e)) self.assertEqual(11, g.size())
def test_load_net_should_try_to_load_poorly_name_files(self): files = ["poorly_named", "a.net.in.some.format", "a"] for name in files: g = nets.load_net(os.path.join(test_net_path, name)) self.assertEqual(11, g.size(), "%s should have 11 nodes, has %d" % (name, g.size()))
def _test_should_load_nets_from_file_streams(self): #:MC: this does not work properly with read_adjlist (at least). it returns 0-sized nets. f = open(os.path.join(test_net_path, "test.adjlist")) g = nets.load_net(f) self.assertEqual(11, g.size()) f.close()
###################### # connectivity print('Generating fixed adjancency matrix.') if args.small_world: connectivity = generate_connectivity(args.img_side, args.num_cn, args.critical_dist, 'small_world') else: connectivity = generate_connectivity(args.img_side, args.num_cn, args.critical_dist, 'local') connectivity = torch.tensor(connectivity).long().unsqueeze(0).to('cpu') batch_connectivity = connectivity.repeat(args.batch_size, 1, 1).to(args.device) ###################### # initialization if torch.cuda.device_count() > 1: model = nn.DataParallel(nets.load_net(args, batch_connectivity)).to(args.device) criterion = nn.DataParallel(nets.criterion(args.time_weight)).to( args.device) else: model = nets.load_net(args, batch_connectivity).to(args.device) criterion = nets.criterion(args.time_weight).to(args.device) print('network contains {} parameters'.format( nets.count_parameters(model))) # parameter number time.sleep(2) loss_history = [] loss_history_test = [] coupling_history = [] displayer = disp.displayer(interactive=args.interactive) if args.intrinsic_frequencies == 'learned':