in ppuda/deepnets1m/loader.py [0:0]
def __getitem__(self, idx):
if self.split == 'predefined':
graph = self.nets[idx]
else:
if self.h5_data is None: # A separate fd is opened for each worker process
self.h5_data = h5py.File(self.h5_file, mode='r')
args = self.nets[idx]
idx = self.h5_idx[idx] if self.h5_idx is not None else idx
cell, n_cells = from_dict(args['genotype']), args['n_cells']
graph = self._init_graph(self.h5_data[self.split][str(idx)]['adj'][()],
self.h5_data[self.split][str(idx)]['nodes'][()],
n_cells)
if self.is_train:
is_conv_dense = sum([n[0] in ['conv_5x5', 'conv_7x7'] for n in
cell.normal + cell.reduce]) > 0
num_params = args['num_params']['imagenet' if self.large_images else 'cifar10'] / 10 ** 6
fc = rand_choice(self.fc_dim, 4) # 64-256
if num_params > 0.8 or not args['glob_avg'] or is_conv_dense or n_cells > 12:
C = self.num_ch.min()
elif num_params > 0.4 or n_cells > 10:
C = rand_choice(self.num_ch, 2) # 16-32
elif num_params > 0.2 or n_cells > 8:
C = rand_choice(self.num_ch, 3) # 16-64
else:
C = rand_choice(self.num_ch) # 16-128
if C <= 64:
fc = rand_choice(self.fc_dim)
args['C'] = C.item()
args['fc_dim'] = fc.item()
net_args = {'genotype': cell}
for key in ['norm', 'ks', 'preproc', 'glob_avg', 'stem_pool', 'C_mult',
'n_cells', 'fc_layers', 'C', 'fc_dim', 'stem_type']:
if key == 'C' and self.split == 'wide':
net_args[key] = args[key] * (2 if self.large_images else 4)
else:
net_args[key] = args[key]
graph.net_args = net_args
graph.net_idx = idx
return graph