Giter Club home page Giter Club logo

firefly-hyperparameter-tuning-for-word2vec-embedding-model's Introduction

FireFly Hyperparameter Tuning for Word2Vec Embedding Model

Motivation

Hyperparameter tuning is a critical step in the development of deep learning models. This project aims to use the FireFly Algorithm to perform hyperparameter tuning for a Word2Vec embedding model. The goal is to leverage meta-heuristic optimization methods to find the best and most optimal hyperparameters.

FireFly Algorithm

In this project, we provide an implementation of the FireFly Algorithm with some additional features, such as:

  • Ensuring that parameters remain within specified ranges.
  • Different parameters are given different scales, respecting their nature as described by the problem.

Example

Below is an example demonstrating how to use the FireFly Algorithm for optimization:

from firefly import FireFlyOptimizer, FireFlyConfig, FireFlyParameterBounder

def fitness(x):
    return x[0]**2 + x[1]**2

configs = FireFlyConfig.get_defaults()
configs.pop_size = 100
configs.max_iters = 10
print(configs)

bounder = FireFlyParameterBounder(bounds=[(-5, 5), (-5, 5)])
print(bounder)

FA = FireFlyOptimizer(config=configs, bounder=bounder)

FA.run(func=fitness, dim=2)

print("Best Fitness:", FA.best_intensity)
print("Best position:", FA.best_pos)
➜  FireFly-Optimizer-Deep-Learning git:(main) ✗ python3 firefly_example.py

FireFlyConfig(pop_size=100, alpha=1.0, beta0=1.0, gamma=0.01, max_iters=10, seed=None)
FireFlyParameterBounder(bounds=[(-5, 5), (-5, 5)])
Best Fitness: 0.009908765479110442
Best position: [0.06986411 0.07090678]

Hyperparameter Tuning With FireFly

To use FireFly as an optimizer for hyperparameter tuning, run the following command and specify some arguments:

➜ python3 hyperparam.py --popsize=5 --alpha=1.0 --beta0=1.0 --gamma=0.01 --maxiters=5 

Train CBoW Model

After obtaining the optimal hyperparameters with the previous scripts, let's train a CBoW Embeddings model with these parameters:

➜ python3 train.py --lr=0.0066 --beta1=0.899 --beta2=0.9989 --windowsize=1 --embdim=2 --epochs=50

firefly-hyperparameter-tuning-for-word2vec-embedding-model's People

Contributors

jamormoussa avatar

Stargazers

ANAS NOURI avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.