Skip to content

Instantly share code, notes, and snippets.

View mickypaganini's full-sized avatar

Michela Paganini mickypaganini

View GitHub Profile
def set_reproducible_seed(seed):
import torch
import numpy as np
import random
import os
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
@mickypaganini
mickypaganini / numpythia_pyjet.ipynb
Created December 19, 2017 22:03
numpythia and pyjet (aka: Pythia and FastJet)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mickypaganini
mickypaganini / gradients.py
Created September 28, 2017 16:21
Get magnitude of gradients from keras Model
# model is a keras Model
weights = model.weights # weight tensors
gradients = model.optimizer.get_gradients(model.total_loss, weights) # gradient tensors
import keras.backend as K
input_tensors = [model.inputs[0], # input data
model.sample_weights[0], # sample weights
model.targets[0], # labels
K.learning_phase(), # train or test mode
]
@mickypaganini
mickypaganini / variable_angle_position.ipynb
Created June 15, 2017 21:43
Validation of samples produced with variable angle and position
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mickypaganini
mickypaganini / shuffle_jets.py
Last active May 16, 2017 15:10
Not the most intelligent way of doing it, but it works.
d = io.load('yourfile.hdf5')
#ix = [random.sample(range(4), 4) for _ in xrange(d['X'].shape[0])]
ix = np.argsort(d['X'][:, :4])[:, ::-1]
def _pairwise(iterable):
'''s -> (s0, s1), (s2, s3), (s4, s5), ...'''
a = iter(iterable)
return izip(a, a)
cols = list(_pairwise(range(d['X'].shape[-1])[::4])) # or you can just type [(0, 4), (8, 12), (16, 20), (24, 28)]
@mickypaganini
mickypaganini / performance_plots.ipynb
Created November 4, 2016 00:03
1tagRNN performance plots
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mickypaganini
mickypaganini / install-env.sh
Last active November 3, 2016 05:04
Set up environment for HEP
#!/usr/bin/env bash
# ** TO USE ROOT, type load_root after all of this has been installed **
# GENERAL SETUP
################
# env usefulness
PYTHON_VERSION="2.7.10"
PY_PAYLOAD="Python-${PYTHON_VERSION}.tgz"
@mickypaganini
mickypaganini / test_ntuples.ipynb
Last active September 20, 2016 19:41
Testing Dan's latest ntuple production
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mickypaganini
mickypaganini / checkMV2c10.ipynb
Last active June 1, 2016 12:40
Check ROC curve for MV2c10 between Dan's ntuples and v47 ntuples
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.