Skip to content

Instantly share code, notes, and snippets.

View riga's full-sized avatar

Marcel Rieger riga

View GitHub Profile
@riga
riga / gist:e776812d53b748cdf51a
Last active August 29, 2015 14:09 — forked from arngarden/gist:6087798
Simple pylearn2 XOR setup with training and prediction
import theano
from pylearn2.models import mlp
from pylearn2.training_algorithms import sgd
from pylearn2.termination_criteria import EpochCounter
from pylearn2.datasets.dense_design_matrix import DenseDesignMatrix
import numpy as np
from random import randint
class XOR(DenseDesignMatrix):
@riga
riga / hipchat_thecodinglove_integration.py
Last active August 29, 2015 14:23
HipChat Integration parsing the TheCodingLove.com feed
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
HipChat integration that parses the thecodinglove.com feed and sends
new posts to a HipChat room.
Dependencies:
requests, https://pypi.python.org/pypi/requests
feedparser, https://pypi.python.org/pypi/feedparser
@riga
riga / test_tf20_cmssw.sh
Created October 21, 2019 16:24
Test the TensorFlow 2.0 installation in CMSSW.
#!/usr/bin/env bash
action() {
export SCRAM_ARCH="slc7_amd64_gcc820"
export CMSSW_VERSION="CMSSW_11_0_0_pre9"
if [ ! -d "$CMSSW_VERSION" ]; then
scramv1 project CMSSW "$CMSSW_VERSION"
cd "$CMSSW_VERSION/src"
@riga
riga / read_pdf.py
Last active October 30, 2019 13:20
Read PDF values from MiniAOD
# coding: utf-8
import os
def fwlite_loop(path, handle_data=None, start=0, end=-1, object_type="Event"):
"""
Opens one or more ROOT files defined by *path* and yields the FWLite event. When *handle_data*
is not *None*, it is supposed to be a dictionary ``key -> {"type": ..., "label": ...}``. In that
@riga
riga / patch_graph.py
Created November 27, 2019 13:52
Patch a TensorFlow graph
# coding: utf-8
import os
import tensorflow as tf
def read_constant_graph(graph_path, create_session=True, as_text=False):
graph = tf.Graph()
with graph.as_default():
@riga
riga / test_tf20.sh
Created November 27, 2019 14:23
cmsdist and cmssw setup for tf2.0
action() {
local base="$( /bin/pwd )"
git clone https://github.com/cms-sw/pkgtools.git
git clone --single-branch --branch tf-2.0 https://github.com/riga/cmsdist.git
./pkgtools/cmsBuild -i tf-2.0 -c cmsdist/ --repository cms.week0 --arch slc7_amd64_gcc820 -j 10 build cmssw-tool-conf --no-cleanup
export SCRAM_ARCH="slc7_amd64_gcc820"
export CMSSW_VERSION="CMSSW_11_0_0_pre12"
@riga
riga / pyrefs.py
Created January 22, 2020 12:52
Python reference count manipulation
# coding: utf-8
import sys
import gc
import ctypes
# configuration of Py_IncRef and Py_DecRef
_c_inc_ref = ctypes.pythonapi.Py_IncRef
@riga
riga / test_deepjet.py
Last active January 24, 2020 12:55
CMSSW TensorFlow 1.13.1 evaluation test for the DeepFlavor tagger
# coding: utf-8
"""
Test evaluation script for the DeepJet tagger.
Input dimensions and names from
https://github.com/cms-sw/cmssw/blob/02d4198c0b6615287fd88e9a8ff650aea994412e/RecoBTag/TensorFlow/plugins/DeepFlavourTFJetTagsProducer.cc
"""
import os
@riga
riga / cmssw_tf_thread_pools.h
Last active January 28, 2020 13:00
Custom CMSSW TF ThreadPools
// custom TensorFlow ThreadPool implementations for CMSSW
#include "tensorflow/core/lib/core/threadpool.h"
#include "tbb/task_arena.h"
#include "tbb/task_group.h"
// thread pool that schedules all tasks within the caller thread
class NoThreadPoolImpl : public tensorflow::thread::ThreadPoolInterface {
public:
@riga
riga / testDeepJetPerformance.cc
Last active February 4, 2020 16:45
CMS DeepJet performance test between TF and ONNX
/*
* Performance test of the DeepJet model with both TensorFlow and ONNXRuntime.
* Place this file into a cmssw test directory and add the following to the BuildFile.xml:
*
* <bin name="testTFDeepJetPerformance" file="testRunner.cpp,testDeepJetPerformance.cc">
* <use name="cppunit" />
* <use name="FWCore/Utilities" />
* <use name="PhysicsTools/TensorFlow" />
* <use name="PhysicsTools/ONNXRuntime" />
* </bin>