Skip to main content

NUAIM - Black-Box Generator for Meta-Variable Optimization

NUAIM is a Python package designed for Black-Box Optimization (BBO). It acts as a black-box generator for meta-variable (or hierarchical variable) optimization, a feature that is rarely available in black-box generators. With NUAIM, you can explore and optimize complex neural network architectures and hyperparameters in a structured and extensible way.

✨ Features

  • 🧠 Black-Box Generator: Generate and evaluate neural network architectures as black-box functions for optimization.
  • 📊 Meta-Variable Optimization: Supports hierarchical variables, enabling optimization of both architecture and hyperparameters.
  • 🔧 Flexible Hyperparameter Management: Easily customize optimizers, learning rates, and other parameters.
  • 📈 Detailed Performance Metrics: Logs training time, forward pass time, and accuracy for each model.
  • 🎯 Preset Configurations: Ready-to-use presets for MLPs, CNNs, Transformers, and hybrid architectures.
  • 🔄 Modular Design: Clean and extensible architecture for research and experimentation.
  • 📝 Rich Logging: Save results in table and JSON formats for easy analysis.
  • 🚀 Easy Integration: Simple Python API for seamless integration into your workflows.

🚀 Quick Start

Installation

Install NUAIM using pip:

pip install nuaim

Basic Usage

What is Possible with sample_instance

The sample_instance method allows you to:

  • Train multiple models with different configurations
  • Log results in various formats (table, JSON, or both)
  • Track training and forward pass times

Optional parameters for sample_instance:

  • dataset_frac: Fraction of the dataset to use (default: 1)
  • num_samples: Number of models to sample (default: 5)
  • max_epochs: Maximum number of training epochs (default: 1000)
  • filename: Name of the file to save results (default: None)
  • log_dir: Directory to save logs (default: "logs")
  • verbose: Whether to print progress (default: True)
  • output_format: Format of the output ("table", "json", or "both", default: "both")
  • track_train_time: Track training time (default: True)
  • track_forward_time: Track forward pass time (default: True)
  • custom_params: Custom hyperparameters (default: None)

Simple Implementation of sample_instance

from nuaim import ModelFactory

# Create a model factory with a preset configuration
factory = ModelFactory("BasicMLP")

# Train multiple models and get results
results = factory.sample_instance(
    num_samples=10,
    max_epochs=20,
    filename="experiment_results",
    log_dir="./logs",
    output_format="both",  # "table", "json", or "both"
    track_train_time=True,
    track_forward_time=True
)

print(f"Best accuracy: {results['best_accuracy']:.4f}")
print(f"Average accuracy: {results['average_accuracy']:.4f}")

What is Possible with factory.train

The factory.train method allows you to:

  • Train a single model with specific hyperparameters
  • Customize training parameters like epochs and verbosity
  • TBD -> Append results to log file

Optional parameters for train:

  • hyper_params: Dictionary of hyperparameters for the model (default: None)
  • max_epochs: Maximum number of training epochs (default: 1000)
  • verbose: Whether to print progress in (default: True)

Simple Implementation of factory.train

# Generate random hyperparameters for a model
hyperparams = factory.generate_random_model_dict()

# Train the model and get accuracy
accuracy = factory.train(
    hyper_params=hyperparams,
    max_epochs=10,
    verbose=True
)

print(f"Model accuracy: {accuracy:.4f}")

📖 Available Presets

NUAIM includes several built-in preset configurations for different levels of complexity:

Basic Presets

  • BasicMLP: Simple multi-layer perceptron configurations
  • BasicCNN: Basic convolutional neural networks
  • BasicTransformer: Simple transformer architectures

Advanced Presets

  • AdvancedMLP: Complex MLP with advanced optimization
  • AdvancedCNN: Advanced CNN architectures
  • AdvancedTransformer: Multi-head attention mechanisms

Hard Presets

  • HardMLP: Complex MLP with extensive hyperparameter spaces
  • HardCNN-MLP: Hybrid CNN-MLP architectures
  • HardTransformer: Advanced transformer configurations

Complete Preset

  • Complete: Comprehensive search space with all layer types.

🔬 Research Applications

NUAIM is ideal for:

  • Black-Box Optimization (BBO): Treat neural network architectures as black-box functions for optimization.
  • Meta-Variable Optimization: Optimize hierarchical variables like architecture and hyperparameters.
  • Neural Architecture Search (NAS): Automate the discovery of optimal architectures.
  • Hyperparameter Tuning: Systematically explore hyperparameter spaces.
  • Model Benchmarking: Compare different architectures and configurations.

🤝 Contributing

We welcome contributions! Please feel free to:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

📄 License

This project is licensed under the MIT License.


Made with ❤️ for the research community

Metadata

Release files for nuaim 1.0.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 nuaim 1.0.0
File Size Uploaded Provenance Actions
nuaim-1.0.0.tar.gz 23.7 kB Without provenance Details for nuaim-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nuaim 1.0.0
File Interpreter ABI Platform Actions
nuaim-1.0.0-py3-none-any.whl Python 3 none any Details for nuaim-1.0.0-py3-none-any.whl

Total release size: 49.2 kB

Release files / nuaim-1.0.0.tar.gz

Download URL nuaim-1.0.0.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
50da3434acb632ece365ca292a6cb56e90e2600465580b60a4ff1115d138b132
BLAKE2b-256 checksum
How to use checksums
cbe98b6445bcc32ecbcaa1ae4359f97bca32045064fdf89a3bd1a332bc928957
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / nuaim-1.0.0-py3-none-any.whl

Download URL nuaim-1.0.0-py3-none-any.whl
Size 25.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fac59c8348042b738cb3631764e42c3d1a444ff8258409e4ffecc532c72ec8c9
BLAKE2b-256 checksum
How to use checksums
9a3b02d130a9ec838a9d6f6a5089599fe58cce27af3b694ac7063106ec3e1d85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Security for nuaim 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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