-
Notifications
You must be signed in to change notification settings - Fork 8
Examples
Ravin D edited this page Oct 9, 2024
·
2 revisions
Here are some practical examples demonstrating how to use PyDeepFlow for different types of neural network models.
# Import necessary modules
import numpy as np
from pydeepflow.model import Multi_Layer_ANN
# Sample data
X_train = np.random.randn(500, 10)
y_train = np.random.randint(0, 2, size=(500, 1))
# Define and compile the model
model = Multi_Layer_ANN(X_train, y_train, hidden_layers=[64], activations=['relu'], loss='binary_crossentropy')
# Train the model
model.fit(epochs=100, learning_rate=0.01)
# Sample data
X_train = np.random.randn(1000, 20)
y_train = np.eye(3)[np.random.randint(0, 3, 1000)] # One-hot encoded labels for 3 classes
# Define and compile the model
model = Multi_Layer_ANN(X_train, y_train, hidden_layers=[64, 32], activations=['relu', 'relu'], loss='categorical_crossentropy')
# Train the model
model.fit(epochs=50, learning_rate=0.001)
For more advanced examples, refer to the Advanced Features section.