| local cjson = require 'cjson' |
| 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)}) |
| local fd = io.open('tests.json', 'r') |
| local tests = cjson.decode(fd:read('*a')) |
| for i, test in ipairs(tests) do |
| algorithm = optim[test.algorithm] |
| for i, config in ipairs(test.config) do |
| print('================================================================================') |
| params = torch.DoubleTensor({1.5, 1.5}) |
| return rosenbrock(x), drosenbrock(x) |
| algorithm(closure, params, config) |
| print(string.format('%.8f\t%.8f', params[1], params[2])) |