Skip to content

raynlamlaika/machine-learning-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AI Math, Machine Learning, CNN, and NLP Library in C

This repository contains a C-based library built from scratch, designed to handle essential mathematical functions and operations for AI, machine learning, deep learning (CNN), and natural language processing (NLP) projects. The library provides implementations of matrix operations, activation functions, loss functions, neural network components, convolution layers, NLP utilities, and optimizers. It aims to offer an in-depth understanding of the core mechanics underlying popular AI libraries like TensorFlow and PyTorch.

Project Overview

This project is divided into multiple stages, beginning with basic mathematical operations and progressing through more advanced deep learning algorithms, including convolutional neural networks (CNNs) and natural language processing (NLP) models. The library serves as both a learning tool and a robust foundational library that can be extended for more complex projects.

Stages of Development

Stage 1: Basic Matrix and Vector Operations

At the foundation of AI and machine learning are matrix and vector computations. These functions allow for basic manipulations that are critical in implementing AI algorithms.

  • Functions Included:
    • create_matrix, add_matrices, multiply_matrices, transpose_matrix
    • dot_product, scalar_multiply_vector, scalar_multiply_matrix

Stage 2: Activation & Loss Functions

Activation functions introduce non-linearity to neural networks, while loss functions calculate errors that guide the learning process.

  • Activation Functions: sigmoid, relu, tanh, softmax
  • Loss Functions: mean_squared_error, binary_cross_entropy, categorical_cross_entropy

Stage 3: Neural Network Components

These functions are the building blocks for implementing custom neural networks from scratch.

  • Functions Included:
    • dense_layer_forward, dense_layer_backward
    • gradient_descent_optimizer, sgd_optimizer

Stage 4: Convolutional and Recurrent Neural Networks

This stage introduces deep learning concepts, including Convolutional Neural Networks (CNN) and Recurrent Neural Networks (RNN).

  • Convolutional Neural Network (CNN) Functions:

    • convolution2d, max_pooling2d, average_pooling2d
    • relu_activation, flatten, batch_normalization_cnn
  • Recurrent Neural Network (RNN) Functions:

    • forward_rnn, backpropagate_rnn
    • generate_text_rnn

Stage 5: Natural Language Processing (NLP)

This section covers the essential NLP functions, from text preprocessing to more advanced models like Word2Vec and transformers.

  • Basic NLP Functions:

    • tokenize_sentence, remove_stopwords, stem_word, lowercase_sentence
    • count_word_frequencies, one_hot_encode, build_vocabulary
  • Advanced NLP Models:

    • tf_idf, cosine_similarity, word2vec, skip_gram, cbow
    • n_gram, predict_next_word, transformer_encoder, transformer_decoder

Stage 6: Advanced Optimizers & Regularization Techniques

This stage enhances the neural network's performance using advanced optimization algorithms and regularization techniques to prevent overfitting.

  • Functions Included:
    • adam_optimizer, rmsprop_optimizer
    • l2_regularization, dropout, batch_normalization

Stage 7: Multithreading & GPU Acceleration (Optional)

For high-performance computation, the library provides support for parallel processing and hardware acceleration.

  • Functions Included:
    • multithreaded_matrix_multiplication
    • gpu_accelerated_convolution

AI Functions Overview

Here's a summary of key AI functions included in the library:

  • Matrix and Vector Operations:

    • Perform essential operations on matrices and vectors, which are fundamental to any machine learning algorithm.
  • Activation & Loss Functions:

    • Functions like relu, softmax, sigmoid, and cross-entropy are key components of neural networks.
  • Neural Networks:

    • Implement custom neural networks with forward and backward passes for fully connected layers (dense_layer).
  • CNN & RNN Functions:

    • Implement convolutional layers (convolution2d, pooling) for image-based tasks and recurrent layers (forward_rnn) for sequential data.

CNN Functions Overview

  • Convolution Layers:

    • convolution2d and pooling operations allow for building deep CNN architectures.
  • Activation Functions:

    • relu_activation applies a non-linear transformation after each convolution.
  • Pooling Layers:

    • max_pooling2d and average_pooling2d reduce spatial dimensions while preserving important features.
  • Advanced Techniques:

    • batch_normalization_cnn normalizes outputs between layers, speeding up training.

NLP Functions Overview

  • Tokenization & Preprocessing:

    • Basic NLP functions like tokenize_sentence and remove_stopwords help in text preprocessing.
  • Word Embeddings:

    • Functions like word2vec and skip_gram create embeddings for words, which are useful for language models.
  • Transformer Models:

    • transformer_encoder and transformer_decoder functions enable transformer-based models for state-of-the-art NLP applications.

Future Work

  • Additional deep learning architectures (e.g., LSTM, GRU).
  • Transformer-based models like BERT and GPT.
  • GPU support for more AI-related operations.

How to Contribute

Contributions are welcome! Whether it’s optimizing the code, adding new features, or improving documentation, feel free to open a pull request or submit an issue.

About

in library for machine learning and ia in c

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages