Skip to content

RichardAragon/DFAF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deterministic Fractal Activation Function (D-FAF)

Conceptualization

The D-FAF aims to capture fractal patterns deterministically within an activation function. Unlike PFAF, which introduces probabilistic elements, D-FAF provides a predictable, self-similar transformation that can be leveraged in linear algebra operations.

Proposed Formula

We define the D-FAF as an iterative function that applies a deterministic fractal transformation to its input:

[ {D-FAF}(x) = \lim_{n \to \infty} f^{(n)}(x) ]

where ( f^{(n)}(x) ) is recursively defined as:

[ \begin{cases} f^{(0)}(x) = x \ f^{(n)}(x) = x \cdot \sin(a \cdot f^{(n-1)}(x)) \end{cases} ]

  • ( x ): Input vector or scalar.
  • ( a ): Scaling constant controlling the "frequency" of the fractal pattern.
  • ( n ): Number of iterations to approximate the fractal behavior.

Code Implementation

Below is a Python implementation of the D-FAF:

import numpy as np

def d_faf(x, a=1.0, n_iterations=10):
    """
    Deterministic Fractal Activation Function (D-FAF)

    Parameters:
    - x: Input array or scalar.
    - a: Scaling constant.
    - n_iterations: Number of iterations.

    Returns:
    - Transformed input after applying D-FAF.
    """
    y = x
    for _ in range(n_iterations):
        y = x * np.sin(a * y)
    return y

Explanation

  • Initialization: Start with ( y = x ).
  • Iteration: Update ( y ) using the recursive formula ( y = x \cdot \sin(a \cdot y) ).
  • Parameters:
    • a: Controls the fractal pattern's complexity.
    • n_iterations: Determines the depth of the fractal transformation.

Combining D-FAF and P-FAF for Encoder/Decoder Systems

Encoder using D-FAF

The deterministic nature of D-FAF makes it suitable for encoding data into a fractal space where patterns are preserved and transformations are reversible under certain conditions.

Decoder using P-FAF

The PFAF introduces controlled randomness, allowing the decoder to handle noise and variations, thus reconstructing the original input from the encoded data.


Probabilistic Fractal Activation Function (P-FAF) Implementation

Here's a sample implementation of P-FAF for completeness:

def p_faf(x, a=1.0, n_iterations=10, noise_level=0.1):
    """
    Probabilistic Fractal Activation Function (P-FAF)

    Parameters:
    - x: Input array or scalar.
    - a: Scaling constant.
    - n_iterations: Number of iterations.
    - noise_level: Standard deviation of the Gaussian noise.

    Returns:
    - Transformed input after applying P-FAF.
    """
    y = x
    for _ in range(n_iterations):
        noise = np.random.normal(0, noise_level, size=np.shape(x))
        y = x * np.sin(a * y) + noise
    return y

Example Usage

# Sample input data
x = np.linspace(-2 * np.pi, 2 * np.pi, 500)

# Encoding with D-FAF
encoded = d_faf(x, a=2.0, n_iterations=10)

# Decoding with P-FAF
decoded = p_faf(encoded, a=2.0, n_iterations=10, noise_level=0.05)

# Visualization (optional)
import matplotlib.pyplot as plt

plt.figure(figsize=(12, 6))
plt.plot(x, x, label='Original Input')
plt.plot(x, encoded, label='Encoded (D-FAF)')
plt.plot(x, decoded, label='Decoded (P-FAF)')
plt.legend()
plt.show()

Interpretation

  • Original Input: The initial data before any transformation.
  • Encoded (D-FAF): Data after applying the deterministic fractal transformation.
  • Decoded (P-FAF): Reconstruction of the original data, with added robustness due to the probabilistic element.

Applications and Benefits

  • Data Compression: The fractal encoding can capture essential patterns in the data efficiently.
  • Noise Reduction: The probabilistic decoding can help in reconstructing signals with reduced noise.
  • Pattern Recognition: Fractal transformations can enhance features useful for machine learning models.

Customization and Tuning

  • Scaling Constant ( a ):
    • Higher values increase the frequency of the fractal pattern.
    • Should be tuned based on the specific characteristics of the input data.
  • Number of Iterations:
    • More iterations lead to a deeper fractal pattern.
    • Balance between computational cost and desired fractal depth.
  • Noise Level in P-FAF:
    • Controls the amount of randomness during decoding.
    • Lower values make the decoder more deterministic.

Conclusion

By integrating D-FAF and P-FAF, we establish a robust encoder-decoder framework that leverages deterministic fractal patterns for encoding and probabilistic elements for decoding. This combination can enhance data representation, compression, and resilience to noise.


Feel free to adjust the parameters and integrate these functions into your models. If you have further questions or need assistance with specific applications, let me know!

About

Deterministic Fractal Activation Function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors