def system_check(): import traceback try: import torch from olympus.models import Model from olympus.optimizers import Optimizer batch = torch.randn((32, 3, 64, 64)).cuda() model = Model('resnet18', input_size=(3, 64, 64), output_size=(10, )).cuda() model.init() optimizer = Optimizer('sgd', params=model.parameters()) optimizer.init(**optimizer.defaults) optimizer.zero_grad() loss = model(batch).sum() optimizer.backward(loss) optimizer.step() return True except: error(traceback.format_exc()) return False
@staticmethod def get_space(): return { 'l1': 'uniform(32, 64, discrete=True)', 'l2': 'uniform(32, 64, discrete=True)', 'l3': 'uniform(32, 64, discrete=True)', 'l4': 'uniform(32, 64, discrete=True)' } # Register my model builders = {'my_model': MyCustomNASModel} if __name__ == '__main__': model = Model( model=MyCustomNASModel, input_size=(290,), output_size=(10,), # Fix this hyper-parameter right away l1=21 ) # If you use an hyper parameter optimizer, it will generate this for you model.init(l2=33, l3=33, l4=32) input = torch.randn((10, 290)) out = model(input) print(out)