Skip to content

Instantly share code, notes, and snippets.

@lgray
lgray / column_combinatorics.py
Created July 8, 2020 20:26
examples of doing heterogenous combinations in awkward0
from uproot_methods import TLorentzVectorArray
import awkward as ak
from coffea.nanoaod import NanoEvents
def make_labeled_p4(x, indices, itype):
p4 = TLorentzVectorArray.from_ptetaphim(x.pt, x.eta, x.phi, x.mass)
return ak.JaggedArray.zip(p4=p4,
ptype=itype*x.pt.ones_like().astype(np.int),
pidx=indices
charge=x.charge)
import os
import os.path as osp
import math
import numpy as np
import torch
import gc
import torch.nn as nn
import torch.nn.functional as F
import torch_geometric.transforms as T
import torch
import torch_geometric
from torch import nn
from torch_geometric.nn.conv import EdgeConv
class EdgeNetWithCategoriesJittable(nn.Module):
def __init__(self, input_dim=3, hidden_dim=8, output_dim=4, n_iters=1, aggr='add',
norm=torch.tensor([1./500., 1./500., 1./54., 1/25., 1./1000.])):
super(EdgeNetWithCategoriesJittable, self).__init__()
Sharing from a friend.....
This chilled me to the bone. This problem is outrageously out of control....and this...so insightful. TIME TO WAKE UP!
(I am not the original creator of this post)
“Can you tell the difference between these kids? Can you tell if they’re sad or asking for help? Could you pick them out in a crowd of 1000 people? By requiring kids to wear masks - whether it’s in stores, in schools, or a public place - you are robbing them of their ONE hope of being found in the event that they get taken - their faces.
Did you know that more than 2,000 missing-child reports are filed each day, and that many of them can be found when parents provide specific details about their physical appearance and a photo of THEIR FACE?
Did you KNOW that a child in AMERICA is over 66,000 x more likely to be human trafficked than to get COVID-19?
So DO YOU REALIZE that by requiring children over the age of 2 to wear a mask, you are making child abduction & human trafficking SO MUCH EASIER on the offenders?
Don’t bel
import torch
import numpy as np
import awkward as ak
def make_embedding_truth(truth_label_by_hits, device='cpu'):
truth_ordering = np.argsort(truth_label_by_hits)
uniques, counts = np.unique(truth_label_by_hits, return_counts=True)
truth_indices = ak.JaggedArray.fromcounts(counts, truth_ordering) # delete noise?
pairwise_truth = truth_indices.choose(2)
other_samples = np.zeros(pairwise_truth.counts.sum() + (pairwise_truth.counts==0).sum(), dtype=np.int64)
def forward(self, x, batch: OptTensor=None):
x = self.datanorm * x
x = self.inputnet(x)
for ec in self.edgeconvs:
edge_index = knn_graph(x, self.k, batch, loop=False, flow=ec.flow)
x = ec(x, edge_index)
out = self.output(x) # output the embedding directly from the dgcnn
#!/bin/bash
cmsrel CMSSW_11_1_0_pre6
cd CMSSW_11_1_0_pre6/src
cmsenv
git cms-init
git remote add thomas-cmssw [email protected]:tklijnsma/cmssw.git
git fetch thomas-cmssw dev-finecalo:dev-finecalo
git cms-merge-topic tklijnsma:dev-finecalo
git checkout dev-finecalo
@lgray
lgray / efficiency.py
Last active September 29, 2020 17:45
code for making efficiency plots
pt_true = []
matched_pt_true = []
pred_pt = []
eta_true = []
matched_eta_true = []
pred_eta = []
phi_true = []
matched_phi_true = []
@lgray
lgray / graphmet_embedding.py
Created October 8, 2020 20:26
graphmet with embeddings
class GraphMETNetwork(nn.Module):
def __init__ (self, continuous_dim, cat_dim, output_dim=1, hidden_dim=32, conv_depth=1):
super(GraphMETNetwork, self).__init__()
self.embed_charge = nn.Embedding(3, hidden_dim//4)
self.embed_pdgid = nn.Embedding(8, hidden_dim//4)
self.embed_pv = nn.Embedding(2, hidden_dim//4)
self.embed_continuous = nn.Sequential(nn.Linear(continuous_dim,hidden_dim),
nn.ReLU(),
class GraphMETNetwork(nn.Module):
def __init__ (self, continuous_dim, cat_dim, output_dim=1, hidden_dim=32, conv_depth=1):
super(GraphMETNetwork, self).__init__()
self.embed_charge = nn.Embedding(3, hidden_dim//4)
self.embed_pdgid = nn.Embedding(8, hidden_dim//4)
self.embed_pv = nn.Embedding(2, hidden_dim//4)
self.embed_continuous = nn.Sequential(nn.Linear(continuous_dim,hidden_dim//2),
nn.ELU(),