Pyray2 is a deep learning framework implemnted from scratch using python and libraries such as numpy, matplotlib, pandas.
$ pip install pyray2
Check Colab:
- Convolution 2D
- Dense
- Max Pooling
- Avg Pooling
- Sigmoid
- RelU
- Softmax
- Tanh
- Mean Square Error
- Cross Entropy
How to define a Model:
# Example
model = Model()
model.add(conv(1, 4, 3, padding=1))
model.add(MaxPool2D(kernel_size=(2,2)))
model.add(ReLU())
model.add(Flatten())
model.add(Dense(8*7*7, 10))
model.set_loss(CrossEntropyLoss())
- Gradiant Decent
- Momentum
- Adam
optim = GradientDecent(model.parameters(), learning_rate = 0.01)
optim = MomentumGD(model.parameters(), learning_rate = 0.01)
optim = Adam(model.parameters(), learning_rate = 0.01)
lr_schedular = StepLR(optimizer, step_size = 1, gamma=0.1)
- View dataset's examples
- Plotting for loss
- live graph
# Show Dataset Examples
image, labels = dataloader.__getitem__(1)
images = image.T.reshape(batch_size, 1, width, height)
images = np.asarray(images)
img_viewer_examples(images, labels.tolist()[0], greyscale= True)
# Plotting Loss
model.graph()
# Training Loop ...
# Before the loop to start new thread
model.startGraph()
# Training Loop ...
# After the loop to close the thread
model.stopGraph()
- Precision
- Recall
- F1 Score
e = Evaluation(10)
for image, label in dataloader_test:
predicted = .....
pred = .....
e.add_prediction(pred[np.newaxis],label)
print("the confusion Matrix :",e.get_confusion_Matrix())
print("the Mean F1 Score =",e.evaluate())
- CSV dataset loading
- Batch loading by Data Loader
- Interface for MNIST & CIFAR-10 datasets
- Simillar to Pytorch Interface.
batch_size = 4
dataset = MNIST_dataset("train.csv")
dataloader = Data_Loader(dataset, batch_size)
for image, label in dataloader:
...
...
- Saving / Loading model weights through .pth files.
model = load_weights(path)
save_weights(model, path)
- LeNet
- AlexNet