Skip to main content

parallel neural network layer for binarization of ternarization - quantized layers from the beginning

Project description

plinear

Github for parrallel - linear layer

You can install PLinear using pip:

pip install plinear

idea inspired from

https://arxiv.org/pdf/2402.17764?trk=public_post_comment-text

code inspired from

https://github.com/kyegomez/BitNet/blob/main/bitnet/bitlinear.py

Ideas and Road Map

parrallel neural network (PLinear)

Binarizing ternary layers by making posNet and negNet and add them.

No activation function required.

Suggested usage :

import torch
import torch.nn as nn
from plinear import PLinear

class SimpleNN(nn.Module):
    def __init__(self):
        super(SimpleNN, self).__init__()
        self.fc1 = PLinear(28*28, 128)
        self.fc2 = PLinear(128, 10)

    def forward(self, x):
        x = torch.flatten(x, 1)
        x = self.fc1(x)
        x = self.fc2(x)
        return x

# Example usage
model = SimpleNN()
print(model)

visualization (Not finised for documentation)

Brute Force optimization of 3 x 3 CNN (Only Idea)

Since I parrallelized layers, each 3 x 3 CNN layer can be brute forced in 2^9 * 2 weights for ternary, which is very cheap against previous models.

Even the model is same, the layer is still at least 9 times smaller even if the model seeked through every cases.

And we can reduce the model with simple searching tasks.

I believe this can be used to vectorize images in proper size of vector which can be reused for image generation or more.

I guess vectorizing concepts and dynamically allocating them with layers would be the final goal of this project.

complex layers (Only Idea)

Develope Note

15, July, 2024

Checked plinear works on colab

16, July, 2024

version 0.1.2.2.

changelog

0.1.1.2.

Documented readme.md

Preflight testing done for mnist both layer and visualization.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plinear-0.1.2.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plinear-0.1.2.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file plinear-0.1.2.2.tar.gz.

File metadata

  • Download URL: plinear-0.1.2.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Darwin/23.5.0

File hashes

Hashes for plinear-0.1.2.2.tar.gz
Algorithm Hash digest
SHA256 263dd62bf753e774aad8d00e17fd8aa892b1704d8fe534c48e64824a84347a65
MD5 a1526f7ae2de91c5520fe3493ccd14a0
BLAKE2b-256 1a676e4fb01f18b3c1cf5c1056cd5ae1ff140cd9bed9bc430089bc5432061434

See more details on using hashes here.

File details

Details for the file plinear-0.1.2.2-py3-none-any.whl.

File metadata

  • Download URL: plinear-0.1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Darwin/23.5.0

File hashes

Hashes for plinear-0.1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 200e731cb89c8aca35b4d41714a7261cb88ceb5f548fe99f9526bd49210a6073
MD5 2c83da722645e582c1ec78bc972f2c3a
BLAKE2b-256 9bd0adf59640ec79551b02845acc06bdebd896b094a529238c41f909d709c00e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page