Skip to main content

A simple utility for generating CNN architectures automatically, using genetic algorithms.

Project description

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 article:

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

Project details


Download files

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

Source Distribution

easynas-0.2.tar.gz (7.6 kB view hashes)

Uploaded Source

Built Distribution

easynas-0.2-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page