def test_VerboseClassifier(self): nn = MLPC(layers=[L("Softmax")], verbose=1, n_iter=1) a_in, a_out = numpy.zeros((8,16)), numpy.zeros((8,1), dtype=numpy.int32) nn.fit(a_in, a_out) assert_in("Epoch Training Error Validation Error Time", self.buf.getvalue()) assert_in(" 1 ", self.buf.getvalue()) assert_in(" N/A ", self.buf.getvalue())
def test_CaughtRuntimeError(self): nn = MLPC(layers=[L("Linear")], learning_rate=float("nan"), n_iter=1) a_in, a_out = numpy.zeros((8, 16)), numpy.zeros((8, 1), dtype=numpy.int32) assert_raises(RuntimeError, nn.fit, a_in, a_out) assert_in("A runtime exception was caught during training.", self.buf.getvalue())
def check(self, a_in, a_out, a_mask, act='Softmax'): nn = MLPC(layers=[L(act)], learning_rule='adam', learning_rate=0.05, n_iter=250, n_stable=25) nn.fit(a_in, a_out, a_mask) return nn.predict_proba(a_in)
def test_Classifier(self): a_in = numpy.random.uniform(0.0, 1.0, (64, 16)) a_out = numpy.random.randint(0, 4, (64, )) cross_val_score(MLPC(layers=[L("Linear")], n_iter=1), a_in, a_out, cv=5)
def test_GetParamValues(self): nn = MLPC(layers=[L("Linear")], learning_rate=0.05, n_iter=456, n_stable=123, valid_size=0.2, dropout_rate=0.25) params = nn.get_params() self.check_values(params)
def test_CloneWithValues(self): nn = MLPC(layers=[L("Linear")], learning_rate=0.05, n_iter=456, n_stable=123, valid_size=0.2, dropout_rate=0.25) cc = clone(nn) params = cc.get_params() self.check_values(params)
def test_SingleVote(self): a_in, a_out = numpy.random.uniform(0.0, 1.0, (64, 16)), numpy.zeros( (64, )) vc = VotingClassifier([('nn1', MLPC(layers=[L("Softmax")], n_iter=1))]) vc.fit(a_in, a_out) vc.predict(a_in)
def check(self, a_in, a_out, a_mask, act='Softmax', n_iter=100): nn = MLPC(layers=[L(act)], learning_rule='rmsprop', n_iter=n_iter) nn.fit(a_in, a_out, a_mask) return nn.predict_proba(a_in)
def setUp(self): cc = MLPC(layers=[L("Sigmoid")], n_iter=1) self.nn = clone(cc)
def test_RepresentationConvolution(self): nn = MLPC(layers=[C("Rectifier")]) r = repr(nn) assert_equal(str, type(r)) assert_in("sknn.nn.Convolution `Rectifier`", r)
def setUp(self): self.nn = MLPC(layers=[L("Linear")], n_iter=1)
def test_RepresentationDenseLayer(self): nn = MLPC(layers=[L("Gaussian")]) r = repr(nn) assert_equal(str, type(r)) assert_in("sknn.nn.Layer `Gaussian`", r)
def test_ConvertToString(self): nn = MLPC(layers=[L("Gaussian")]) assert_equal(str, type(str(nn)))
def test_CloneDefaults(self): nn = MLPC(layers=[L("Gaussian")]) cc = clone(nn) params = cc.get_params() self.check_defaults(params)
def test_GetParamDefaults(self): nn = MLPC(layers=[L("Gaussian")]) params = nn.get_params() self.check_defaults(params)
def setUp(self): self.nn = MLPC(layers=[L("Softmax")], n_iter=1)
def setUp(self): cc = MLPC(layers=[L("Linear")], n_iter=1) self.nn = clone(cc)
def test_Representation(self): nn = MLPC(layers=[L("Gaussian")]) assert_equal(str, type(repr(nn)))