neuroprob/utils/stats.py
def fit(self, x, y, xs, device, iters=1000):
        """
        Probabilistic MAP fitting of spline (loss with regularizer)
        """
        f = Parameter(torch.tensor(y, device=device))
        y_ = torch.tensor(y, device=device)

        optimizer = optim.Adam([shift], lr=1e-2)

        losses = []
        for k in range(iters):
            optimizer.zero_grad()
            f_ = self.interp(x, f.data.cpu(), xs)
            grads
            loss = ((y_ - f)**2).sum() + grads
            loss.backward()
            optimizer.step()
            losses.append(loss.cpu().item())
            
        return f.data.cpu().numpy(), losses

        Probabilistic MAP fitting of spline (loss with regularizer)
        
Probabilistic MAP fitting of spline (loss with regularizer)
Probabilistic MAP fitting of spline ( loss with regularizer )
def fit(self, x, y, xs, device, iters=1000):
        f = Parameter(torch.tensor(y, device=device))
        y_ = torch.tensor(y, device=device)
        optimizer = optim.Adam([shift], lr=1e-2)
        losses = []
        for k in range(iters):
            optimizer.zero_grad()
            f_ = self.interp(x, f.data.cpu(), xs)
            grads
            loss = ((y_ - f)**2).sum() + grads
            loss.backward()
            optimizer.step()
            losses.append(loss.cpu().item())
        return f.data.cpu().numpy(), losses
def fit ( self , x , y , xs , device , iters = 1000 ) : f = Parameter ( torch . tensor ( y , device = device ) ) y_ = torch . tensor ( y , device = device ) optimizer = optim . Adam ( [ shift ] , lr = 1e-2 ) losses = [ ] for k in range ( iters ) : optimizer . zero_grad ( ) f_ = self . interp ( x , f . data . cpu ( ) , xs ) grads loss = ( ( y_ - f ) ** 2 ) . sum ( ) + grads loss . backward ( ) optimizer . step ( ) losses . append ( loss . cpu ( ) . item ( ) ) return f . data . cpu ( ) . numpy ( ) , losses
Probabilistic MAP fitting of spline (loss with regularizer)
Probabilistic MAP fitting of spline ( loss with regularizer )
"""
        Probabilistic MAP fitting of spline (loss with regularizer)
        """
self
x
y
xs
device
iters