Giter Site home page Giter Site logo

fpga4hep / keras-training Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fastmachinelearning/keras-training

1.0 2.0 3.0 1.39 MB

jet classification and regression training in keras

License: GNU General Public License v3.0

Shell 3.79% Python 96.21%

keras-training's Introduction

keras-training

Installation

Install miniconda2 by sourcing install_miniconda.sh in your home directory. Log out and log back in after this.

cp install_miniconda.sh ~/
cd ~
source install_miniconda.sh

Install the rest of the dependencies:

cd ~/keras-training
source install.sh

Each time you log in set things up:

source setup.sh

Conversion of data

All of the data ntuple files are available here: https://cernbox.cern.ch/index.php/s/AgzB93y3ac0yuId

To add the truth values and flatten the trees (you can skip this step)

cd ~/keras-training/convert
python addTruth.py -t t_allpar \
../data/processed-pythia82-lhc13-*-pt1-50k-r1_h022_e0175_t220_nonu.root

To hadd these files and convert from TTree to numpy array with random shuffling (you can skip this step)

hadd -f \
../data/processed-pythia82-lhc13-all-pt1-50k-r1_h022_e0175_t220_nonu_truth.root \
../data/processed-pythia82-lhc13-*-pt1-50k-r1_h022_e0175_t220_nonu_truth.root
python convert.py -t t_allpar_new \
../data/processed-pythia82-lhc13-all-pt1-50k-r1_h022_e0175_t220_nonu_truth.root

You can also copy this file directly from: https://cernbox.cern.ch/index.php/s/jvFd5MoWhGs1l5v

Training and evaluation

To run a simple training:

cd ~/keras-training/train
python train.py -t t_allpar_new \
-i ../data/processed-pythia82-lhc13-all-pt1-50k-r1_h022_e0175_t220_nonu_truth.z \
-c train_config_threelayer.yml \
-o train_simple/

and evaluate the training:

python eval.py -t t_allpar_new \
-i ../data/processed-pythia82-lhc13-all-pt1-50k-r1_h022_e0175_t220_nonu_truth.z \
-m train_simple/KERAS_check_best_model.h5 \
-c train_config_threelayer.yml \
-o eval_simple/

Pruning and retraining

To prune the trained model by removing weights below a certain threshold (relative weight < 0.2):

mkdir prune_simple_relwmax2e-1
python prune.py -m train_simple/KERAS_check_best_model.h5 \
--relative-weight-max 2e-1 \
-o prune_simple_relwmax2e-1/pruned_model.h5

and evaluate the pruned model:

python eval.py -t t_allpar_new \
-i ../data/processed-pythia82-lhc13-all-pt1-50k-r1_h022_e0175_t220_nonu_truth.z \
-m prune_simple_relwmax2e-1/pruned_model.h5 \
-c train_config_threelayer.yml \
-o eval_simple_relwmax2e-1/

To retrain the pruned model (keeping the pruned weights fixed to 0):

python retrain.py -t t_allpar_new \
-i ../data/processed-pythia82-lhc13-all-pt1-50k-r1_h022_e0175_t220_nonu_truth.z \
-o retrain_simple_relwmax2e-1 \
-m prune_simple_relwmax2e-1/pruned_model.h5  \
-c train_config_threelayer.yml \
-d prune_simple_relwmax2e-1/pruned_model_drop_weights.h5

and evaluate the pruned, retrained model:

python eval.py -t t_allpar_new \
-i ../data/processed-pythia82-lhc13-all-pt1-50k-r1_h022_e0175_t220_nonu_truth.z \
-m retrain_simple_relwmax2e-1/KERAS_check_best_model.h5 \
-c train_config_threelayer.yml \
-o eval_retrain_simple_relwmax2e-1/

keras-training's People

Contributors

jmduarte avatar jngadiub avatar violatingcp avatar vloncar avatar

Stargazers

 avatar

Watchers

 avatar  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.