Skip to main content

GitHub Action Badge codecov GitHub release (latest by date) PyPI - License Downloads GitHub issues

Introduction:

A tensorflow implementation of the Equation Learner Neural Network based model: Imgur

Functionality:

Installation:

pip:

pip install EQL-NN

or from github:

git clone https://github.com/KristofPusztai/EQL.git

Navigate to cloned directory and run setup.py

sudo python setup.py install

Creating and training a model:

from EQL.model import EQL
EQLmodel = EQL(num_layers = 2, dim=5, v = [1,1]) # num_layers -> hidden_layers, dim -> dimension of input, v -> number of binary inputs
x = tf.random_normal_initializer()(shape=(100, 5))
y = tf.random_normal_initializer()(shape=(100, 1))

EQLmodel.build_and_compile(self, metrics=None, loss_weights=None, weighted_metrics=None,
                           run_eagerly=None, kernel_regularizer=None,
                           w_init='random_normal', b_init='random_normal, exclude=None) # exclude specifies activation function exclusions in layers
                           
EQLmodel.fit(x, y, lmbda, t0=100, t1=0, t2=0, initial_epoch=0, verbose=0, batch_size=None, callbacks=None,
        validation_split=0.0, validation_data=None, shuffle=True, class_weight=None,
        sample_weight=None, steps_per_epoch=None,
        validation_steps=None, validation_batch_size=None, validation_freq=1,
        max_queue_size=10, workers=1, use_multiprocessing=False, atol=0.01)

Prediction:

EQLmodel.predict(x, batch_size=None, verbose=0, steps=None, 
                 callbacks=None, max_queue_size=10,
                 workers=1, use_multiprocessing=False)

Note: use tensor input for maximum computational efficiency

Model Information:

There are a variety of methods for understanding what is going on in your model.

EQLmodel.summary() # Provides tensorflow summary
EQLmodel.count_params() # Provides # trainable params
EQLmodel.get_weights(layer) #returns array of layer values
EQLmodel.set_weights(layer, weights) #sets weights of specified layer
EQLmodel.formula(raw_latex=False, reduce=True) # Returns interpretable equations via sympy

EQLmodel.evaluate(x=None, y=None, batch_size=None, verbose=1,
                  sample_weight=None, steps=None,
                  callbacks=None, max_queue_size=10, 
                  workers=1, use_multiprocessing=False,
                  return_dict=False)
# Returns the loss value & metrics values for the model

Can also access the tensorflow model directly to use other TensorFlow functions such as saving:

EQLmodel.model.save('path/to/save')

Implementation Notes:

Training regiment is interpretted as debiased LASSO:

  • T0 epochs are normal training, no regularization
  • T1 epochs are L1 regularized training, continuing where T0 ended
  • T2 epochs are L0 (weights with values close to 0, |w| < atol, are rounded to 0 and left untrained) regularized training, continuing from T1

Check out the jupyter notebook for examples on learning sinusoidal functions: https://github.com/KristofPusztai/EQL/blob/master/Jupyter%20Notebooks/EQLtest.ipynb

Metadata

Release files for EQL-NN 2.1.0

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

Source distribution (sdist)

Source distribution for EQL-NN 2.1.0
File Size Uploaded
eql_nn-2.1.0.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for EQL-NN 2.1.0
File Interpreter ABI Platform
EQL_NN-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.5 kB

Release files / eql_nn-2.1.0.tar.gz

Download URL eql_nn-2.1.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
35b006a11acb1f3d1241461e0eaab7aa62dee39a18727f28097d83e1b5672dc9
BLAKE2b-256 checksum
How to use checksums
eb4715ecf2f29da75e9da388573af36d752da8b29c11ba0a310d4f27a3ea64da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release files / EQL_NN-2.1.0-py3-none-any.whl

Download URL EQL_NN-2.1.0-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47a03ab778271f2ed29872bab71cdccf3a51c255ddcd905c931407155f4eb4d1
BLAKE2b-256 checksum
How to use checksums
e7e534f9441a00f77b374e37b96e66946bfb5c35f4b193f9c39cace4caaae403
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.2

2 release files

2.0.1

2 release files

1.9.6

2 release files

1.9.5

1 release file

1.9.4

1 release file

1.9.3

1 release file

1.9.2

1 release file

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