def test_DenseClassifier(): """Tests probflow.applications.DenseClassifier""" # Data x = np.random.randn(100, 5).astype('float32') w = np.random.randn(5, 1).astype('float32') y = x @ w + 1 y = np.round(1.0 / (1.0 + np.exp(-y))).astype('float32') # Create the model model = apps.DenseClassifier([5, 20, 15, 2]) # Fit the model model.fit(x, y, batch_size=10, epochs=11) # Predictive functions model.predict(x)
def test_MultinomialDenseClassifier(): """Tests probflow.applications.DenseClassifier w/ >2 output classes""" # Data x = np.random.randn(100, 5).astype('float32') w = np.random.randn(5, 3).astype('float32') b = np.random.randn(1, 3).astype('float32') y = x @ w + b y = np.argmax(y, axis=1).astype('int32') # Create the model model = apps.DenseClassifier([5, 20, 15, 3]) # Fit the model model.fit(x, y, batch_size=10, epochs=11) # Predictive functions model.predict(x)