def test_prop_up(self): res = self.rbm.prop_up(self.visible_layer) expected = neur.sigmoid(np.array([[ 1.260987, 2.484167], [ 1.142713, 1.844246], [ 0.878157, 1.070012], [ 0.364556, 0.974234]])) self.assertTrue(self.all_equalish(res, expected))
def encode(self, x): # add ones m = len(x) x = np.hstack([np.ones((m,1)), x]) return neur.sigmoid(np.dot(x, self.encode_weights.transpose()))
def test_prop_up(self): res = self.rbm.prop_up(self.visible_layer) expected = neur.sigmoid( np.array([[1.260987, 2.484167], [1.142713, 1.844246], [0.878157, 1.070012], [0.364556, 0.974234]])) self.assertTrue(self.all_equalish(res, expected))
def prop_up(self, vis_layer): return neur.sigmoid(np.dot(vis_layer, self.weights.transpose()))
def prop_down(self, hid_layer): return neur.sigmoid(np.dot(hid_layer, self.weights))
def test_sigmoid(self): res = neur.sigmoid(np.array(([1, 2], [3, 4]))) target = np.array([[0.7310585, 0.88079708], [0.95257413, 0.98201379]]) self.equalish(res, target)
def prop_down(self, hid_layer): vis_bias = self.expand_visible_bias(hid_layer.shape[0]) return neur.sigmoid(np.dot(hid_layer, self.weights) + vis_bias)
def prop_up(self, vis_layer): hid_bias = self.expand_hidden_bias(vis_layer.shape[0]) res = np.dot(vis_layer, self.weights.transpose()) + hid_bias return neur.sigmoid(res)