In [1]:
require 'nn'
require 'optim'

In [2]:
local matio = require 'matio'
data = matio.load('ex3data1.mat')
X = data.X
y = data.y
numOutput = torch.max(dataset_outputs) - torch.min(dataset_outputs) + 1

In [ ]:
N = 400
A = torch.rand(N, N)
A = A*A:t()
A:add(0.001, torch.eye(N))
b = torch.rand(N)
function sig(x)
    return 1/(1-torch.exp(-x))
end
function J(theta)
    local J = X*t
    grad = 

end

In [ ]:
print(J(torch.rand(N)))

In [ ]:
xs = torch.inverse(A)*b
print(string.format('J(x^*) = %g', J(xs)))

In [ ]:
function dJ(t, X, y, l)
  return X:dot(sig(X*t)-y)/m + l/m*t;
end

In [ ]:
x = torch.rand(N)

In [ ]:
lr = 0.01
for i=1,20000 do
  x = x - dJ(x)*lr
  -- we print the value of the objective function at each iteration
  print(string.format('at iter %d J(x) = %f', i, J(x)))
end