| import torch.legacy.optim as optim |
| from pprint import pprint |
| return (1 - x) ** 2 + 100 * (y - x ** 2) ** 2 |
| return torch.DoubleTensor((-400 * x * (y - x ** 2) - 2 * (1 - x), 200 * x * (y - x ** 2))) |
| 'adadelta': optim.adadelta, |
| 'adagrad': optim.adagrad, |
| 'rmsprop': optim.rmsprop, |
| with open('tests.json', 'r') as f: |
| tests = json.loads(f.read()) |
| print(test['algorithm'] + '\t') |
| algorithm = algorithms[test['algorithm']] |
| for config in test['config']: |
| print('================================================================================\t') |
| params = torch.DoubleTensor((1.5, 1.5)) |
| algorithm(lambda x: (rosenbrock(x), drosenbrock(x)), params, config) |
| print('{:.8f}\t{:.8f}\t'.format(params[0], params[1])) |