This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import scipy.optimize | |
| import scipy.optimize | |
| def norm_or_zero(v): | |
| # normalize vectors along the last axis, avoiding div0 for zero vectors. | |
| denom = np.linalg.norm(v, axis=-1, keepdims=True) | |
| return np.where(denom > 0, v / denom, 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| na = np.loadtxt('../nanoamps') | |
| _,bins,_ = plt.hist(na, bins=40, color='gray', alpha=0.2, density=False); | |
| plt.hist(na.reshape(4,-1).T, bins=bins, histtype='step', density=False); | |
| na_ = na.reshape(4,-1) | |
| plt.hist(np.mean(na_, axis=0), histtype='step', bins=30); | |
| _,bins,_ = plt.hist(na, bins=40, color='gray', alpha=0.2, density=False); | |
| plt.hist(np.std(na_, axis=0, ddof=1), bins=bins); | |
| np.argmax(np.std(na_,axis=0,ddof=1)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| encoder_input = layers.Input( input_shape ) | |
| # ... define encoder sub-network | |
| encoder = keras.models.Model(encoder_input, ...) | |
| decoder_input = layers.Input( latent_shape ) | |
| # ... define decoder sub-network |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import itertools as it | |
| import numpy as np | |
| # calculates ECF for a batch of jet constituents. | |
| # x should have a shape like [batch_axis, particle_axis, 3] | |
| # the last axis should contain (pT, eta, phi) | |
| def ecf_numpy(N, beta, x): | |
| pt = x[:,:,0] | |
| eta = x[:,:,1:2] | |
| phi = x[:,:,2:] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def some_mode(): | |
| auto_input = K.Input((whatever,)) | |
| auto_z = encoder(auto_input) | |
| auto_output = decoder(auto_z) | |
| model = Model(input_layer, output_layer) | |
| loss1_ = K.mean(K.square(auto_input - auto_output)) | |
| loss2_ = K.mean(K.square(auto_z)) | |
| model.hp_loss2_weight = K.variable(1.0, name='loss2_weight') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RotationLayer(layers.Layer): | |
| def __init__(self, theta, learning_phase_only=True, **kwargs): | |
| self.theta = theta | |
| self.vec_dim = dim | |
| self.R = K.constant([[1,0],[0,1]])*tf.cos(theta) \ | |
| + K.constant([[0,-1],[1,0]])*tf.sin(theta) | |
| self.uses_learning_phase = learning_phase_only |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import ROOT as r | |
| import numpy as np | |
| class FatJet: | |
| def __init__(self, tree, idx): | |
| # make an object representing the jet at index `idx` by pulling | |
| # interesting attributes out of the tree. | |
| self.m = tree.fjet_m[idx] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import ROOT as r | |
| import sys | |
| import itertools as it | |
| import numpy as np | |
| import pylab as pl | |
| from scipy.special import cotdg | |
| from scipy.sparse import dok_matrix | |
| def hough_radial(points, radius=5): |
NewerOlder