def update(self,theta): if(self.count % self.update_gap is 0): self.test_errors.append(avg_error(theta, self.test)) self.train_errors.append(self.scaler.scale(avg_error(theta, self.train))) self.costs.append(total_cost(theta, self.train)) self.weight_mags.append(np.dot(theta,theta)) self.count+=1
def test_total_cost(self): net = np.loadtxt('data/braess_net.csv', delimiter=',', skiprows=1) net[:,5] = np.array([2.]*5) flow = np.array([0., 1., 2., 3., 4.]) self.assertTrue(np.linalg.norm(total_cost(flow, net) - 220.) < 1e-8)
def test_total_cost(self): net = np.loadtxt('data/braess_net.csv', delimiter=',', skiprows=1) net[:, 5] = np.array([2.] * 5) flow = np.array([0., 1., 2., 3., 4.]) self.assertTrue(np.linalg.norm(total_cost(flow, net) - 220.) < 1e-8)