Skip to main content

Adaptive Power Neurons

Adaptive Power Neurons is a Python library for building machine learning models using adaptive power perceptrons. These perceptrons dynamically adjust their polynomial feature power and input indices, enabling the model to learn complex patterns effectively.

The library is designed for both regression and classification tasks and supports multi-layer neural networks with adaptive neurons.


Features

  • Dynamic Adaptation: Perceptrons adjust their polynomial degree (power) and input index bias during training.
  • Polynomial Feature Expansion: Supports automatic polynomial feature generation up to a specified degree.
  • Index Bias Adjustment: Incorporates adjustable input bias for feature shifts.
  • Multi-Layer Support: Create flexible, multi-layer neural networks.
  • Customizable Optimizer: Fine-tune hyperparameters like learning rate, polynomial power, and indexing rate dynamically.

Mathematical Overview

1. Polynomial Feature Expansion

Each perceptron transforms the input into a polynomial feature vector: [ \phi(x) = [x^1, x^2, \dots, x^p] ] Where ( p ) is the maximum power specified for the perceptron.

2. Weighted Output

The perceptron computes a weighted sum of the polynomial features: [ z = w_1 \phi(x_1) + w_2 \phi(x_2) + \dots + w_n \phi(x_n) + b ]

3. Loss Function

The library uses Mean Squared Error (MSE) for regression: [ \text{MSE} = \frac{1}{N} \sum_{i=1}^{N} \left( y_i - \hat{y}_i \right)^2 ]

For classification, a step function is used: [ \hat{y} = \begin{cases} 1 & \text{if } z \geq 0 \ 0 & \text{if } z < 0 \end{cases} ]

4. Index Bias Adjustment

An adjustable index bias ( \delta ) shifts the input features: [ x_{\text{adjusted}} = x + \delta ]

5. Weight Updates

Weights, biases, and index bias are updated using gradient descent: [ w_i = w_i - \eta \cdot \frac{\partial \text{MSE}}{\partial w_i}, \quad b = b - \eta \cdot \frac{\partial \text{MSE}}{\partial b}, \quad \delta = \delta - \eta \cdot \frac{\partial \text{MSE}}{\partial \delta} ]


Installation

To install the library, clone the repository and install it locally:

pip install adaptive-power-neurons

# Example Usage for Adaptive Power Neurons

# train_model.py

import numpy as np
from adaptive_power_neurons import AdaptivePowerModel, SGD, DenseLayer

# Hyperparameters
input_dim = 3  # Number of input features
output_dim = 2  # Number of output neurons
max_power = 2  # Max power for the neurons
learning_rate = 0.01  # Learning rate for the optimizer
indexing_rate = 0.001  # Indexing rate

# Create SGD optimizer
optimizer = SGD(learning_rate)

# Create AdaptivePowerModel and add layers
model = AdaptivePowerModel()
model.add(DenseLayer(input_dim, 4, max_power, optimizer, indexing_rate, activation="relu"))
model.add(DenseLayer(4, output_dim, max_power, optimizer, indexing_rate, activation="sigmoid"))

# Dummy dataset
x = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]])  # Input features
y = np.array([[0.5, 1.0], [1.0, 0.0], [0.0, 1.0]])  # Target labels

# Train the model
model.train(x, y, epochs=100, batch_size=1)

Download files

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

Source Distribution

adaptive_power_neurons-0.1.5.6.7.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

adaptive_power_neurons-0.1.5.6.7-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file adaptive_power_neurons-0.1.5.6.7.tar.gz.

File metadata

File hashes

Hashes for adaptive_power_neurons-0.1.5.6.7.tar.gz
Algorithm Hash digest
SHA256 947a4e9dd25b90fa8d63b6f4968113968bba232fe39137cf3011f6c0952ad75c
MD5 b2eb520cba07df757b094d9ce81de7c6
BLAKE2b-256 bf54f6489bf1e9adc1fe1d893ace74b4fd9c0d1dc4ed12bd3c007b8d87fdbcdb

See more details on using hashes here.

File details

Details for the file adaptive_power_neurons-0.1.5.6.7-py3-none-any.whl.

File metadata

File hashes

Hashes for adaptive_power_neurons-0.1.5.6.7-py3-none-any.whl
Algorithm Hash digest
SHA256 17d5c7750ace59f9b1493bc15595aaafc2e87845c1d732fcb38f6a52da8c2f21
MD5 1c2eecb18736f2831dfa41bfa3f3b5af
BLAKE2b-256 b5b691f9569d3baa0d3a4180560c15c43bfe30837dc3c33546e4746a6b384d46

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.1.6.6.7

2 files

This release

0.1.5.6.7 This release

2 files

0.1.5.5.7

2 files

0.1.5.5.5

2 files

0.1.3.5.5

2 files

0.1.2.5.5

2 files

0.1.2.5.4

2 files

0.1.2.5.3

2 files

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