Skip to content

Latest commit

 

History

History
54 lines (46 loc) · 2.16 KB

README.md

File metadata and controls

54 lines (46 loc) · 2.16 KB

EasyNAS - a simple and effective CNN architecture generator

Purpose

Given a dataset, this python package will utilize genetic algorithms and Pytorch to optimize the structure a simple CNN for the task of classification. With simple meaning that the generated architecture is built of a series of layers, where each layers input is the output the previous one.

Installation

pip install easynas

Input data format

The input data should be split into training and validation sets, with the following dimensions:

$$[#samples, #channels, height, width]$$

This means that 2D image-like data is the expected input. If dealing, for example, with 1D time series data that contains a 'channels' dimension, one should include an extra dimension as such (example with numpy):

X = X[:, :, :, None]

Usage example

from easynas.genetic_algorithm import EasyNASGA
import torchvision
from sklearn.model_selection import train_test_split

train_data = torchvision.datasets.MNIST('/files/', train=True, download=True)
test_data = torchvision.datasets.MNIST('/files/', train=False, download=True)
X_train = train_data.data[:, None, :, :].float()
y_train = train_data.targets.float()
X_train, X_val, y_train, y_val = train_test_split(X_train, y_train, test_size=0.2, random_state=42)
easyga = EasyNASGA(X_train, y_train, X_val, y_val, generations=5, population_size=10, max_epochs=1, weight_inheritance=True)
easyga.ga.run()
best_individual = easyga.get_best_individual()
print(f'best individual: {best_individual}')

Credits

Anyone using this package for research/production purposes is requested to cite the following research articles:

Rapaport, E., Poese, I., Zilberman, P., Holschke, O., & Puzis, R. (2020).
Predicting traffic overflows on private peering.
arXiv preprint arXiv:2010.01380.

https://arxiv.org/abs/2010.01380

Rapaport, Elad, Oren Shriki, and Rami Puzis.
"EEGNAS: Neural Architecture Search for Electroencephalography Data Analysis and Decoding."
International Workshop on Human Brain and Artificial Intelligence.
Springer, Singapore, 2019.

https://link.springer.com/chapter/10.1007/978-981-15-1398-5_1