Git Product home page Git Product logo

minimlp's Introduction

miniMLP

This repository contains an implementation of a small Neural Network in Python, with the ability to specify the number of hidden layers, the number of neurons in each layer, and the activation function, and the optimizer to be used.

Installation

pip install miniMLP

Dependencies

The code requires the following dependencies:

  • NumPy
  • matplotlib (for visualization)

Example Usage

Create an instance of the MLP class, specifying the input size, output size, number of hidden layers, sizes of each hidden layer, and activation function.

import numpy as np
from miniMLP.engine import MLP

mlp = MLP(input_size=2, output_size=1, hidden_layers=3, hidden_sizes=[4, 6, 4], activation='relu')

Then, train the MLP using the train method, providing the training data (an array of inputs and corresponding labels), and optional parameters such as the learning rate, number of epochs, and optimizer.

X_train = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
y_train = np.array([[0], [1], [1], [0]])

mlp.train(X_train, y_train, epochs=2000, learning_rate=0.0001, optimizer='Adam')

Finally, use the predict method to obtain predictions for new data points.

y_pred = mlp.predict(X_new)

Activation Functions

The following activation functions are currently supported:

  • Sigmoid
  • ReLU
  • Tanh
  • Softmax
  • Leaky ReLU
  • ELU
  • GELU
  • Softplus
  • SeLU
  • PReLu
  • Swish
  • Gaussian

Optimizers

The following optimizers are currently supported:

  • Adam
  • Stochastic Gradient Descent
  • Momentum

License

This project is licensed under the MIT License. Feel free to use and modify this code for your own projects.

minimlp's People

Contributors

papaaannn avatar

Stargazers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.