Skip to main content

SelfProjection Module for PyTorch

Overview

The SelfProjection module is a PyTorch-based neural network layer designed to transform and project high-dimensional data. It is particularly useful in contexts requiring sophisticated analysis and representation of feature relationships, such as outputs from Transformer models.

Approach

The SelfProjection module employs a dual projection mechanism to process input tensors, capturing different perspectives of the data. Key aspects include:

  • Original and Permuted Projections: The module processes the input tensor in its original form and a permuted form, creating two distinct representations.
  • Relational Interference: By computing relational matrices, the module captures the interplay between different projections, emphasizing the relationships between data dimensions.
  • Normalization: Custom normalization steps, which involve mean subtraction and variance scaling similar to Layer Normalization, are applied to the projections, ensuring stable feature scaling and potentially improved model performance.
  • Trainable Parameters: The module includes several trainable parameters, allowing it to learn optimal feature transformations during training.

Installation

Using pip:

To install the SelfProjection module using pip, simply run the following command:

pip install self-projection

From source:

To install the SelfProjection module, clone this repository and import the module into your PyTorch project.

git clone https://github.com/Sombressoul/self-projection ./self_projection
python -m pip install -e ./self_projection

Usage

Here's a simple example of how to use the SelfProjection with PyTorch:

import torch
from self_projection import SelfProjection

# Define the input tensor dimensions and projection size
input_tensor = torch.randn((batch_size, sequence_length, embedding_dim))
size_projection = 128

# Initialize the SelfProjection module
self_projection = SelfProjection(size_input=input_tensor.size()[1::], size_projection=size_projection)

# Apply the module to the input tensor
projected, relations = self_projection(input_tensor)

print(projected.shape)
# >>> torch.Size([<batch_size>, 128, 128])
print(relations.shape)
# >>> torch.Size([<batch_size>, 128, 128])

Evaluation

(deleted as outdated since 20.01.2024)

Pending.

Future Directions

The ongoing development of the SelfProjection module is a component of a personal endeavor in the field of machine learning. Future plans include conducting experiments with more complex datasets to further assess and refine the module's capabilities. These steps are aimed at exploring a broader range of applications and enhancing the module's performance in diverse settings.

This module is a reflection of my interest in contributing to the machine learning community through individual efforts and is one aspect of a larger personal project dedicated to exploring innovative approaches in the field.

Contribution

Contributions to the SelfProjection module are welcome. Please submit a pull request or open an issue if you have suggestions or improvements.

Metadata

Release files for self-projection 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for self-projection 0.2.2
File Size Uploaded Provenance Actions
self-projection-0.2.2.tar.gz 17.4 kB Without provenance Details for self-projection-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for self-projection 0.2.2
File Interpreter ABI Platform Actions
self_projection-0.2.2-py3-none-any.whl Python 3 none any Details for self_projection-0.2.2-py3-none-any.whl

Total release size: 38.0 kB

Release files / self-projection-0.2.2.tar.gz

Download URL self-projection-0.2.2.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b85ad323523b5552316bf459c2c16967f658acf18c0631302de650f20fbfd165
BLAKE2b-256 checksum
How to use checksums
ac2635b38a3e963d022a7bc4018f5ac6c2066f8aaf780f2ad8eab919038cb176
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / self_projection-0.2.2-py3-none-any.whl

Download URL self_projection-0.2.2-py3-none-any.whl
Size 20.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e535f89b0af42b09a619318190ab68af9c2670684db6a260ba701e470ef5bd4
BLAKE2b-256 checksum
How to use checksums
862159253b2c170f2ee9442957dbf8525f1e9f3716a686f442864fcd66341630
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for self-projection 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page