Skip to content

Instantly share code, notes, and snippets.

View Craigacp's full-sized avatar

Adam Pocock Craigacp

View GitHub Profile
@Craigacp
Craigacp / onnx-rng-writeup.md
Last active December 5, 2024 21:27
ONNX RNG Op Spec Writeup

ONNX RNG Writeup

Introduction

Psuedo-Random Number Generators (PRNGs) provide a stream of random numbers produced by computing specific functions of some hidden state variables. The generation of each random number modifies the state of the PRNG, and the generated random number is a deterministic function of the state. The initial state is a function of some seed value, when left unset this is typically chosen based on the system clock, though this makes the sequence of numbers not reproducible. Typically the PRNGs are designed such that the sequence of generated values has as little statistical correlation as possible, though different PRNG algorithms have different detectable biases. For many PRNGs repeatedly seeding them and drawing a single value will produce a lower quality stream of random numbers in terms of more detectable correlations, than having a single PRNG and drawing from it in sequence. We won't discuss the choice of PRNG algorithm any further, beyond requiring a "splittable" PRNG which

@Craigacp
Craigacp / TensorflowTest.java
Created April 1, 2021 15:46
Tensorflow Java linear regression example
import org.tensorflow.EagerSession;
import org.tensorflow.Graph;
import org.tensorflow.Operand;
import org.tensorflow.Session;
import org.tensorflow.Session.Runner;
import org.tensorflow.Tensor;
import org.tensorflow.TensorFlow;
import org.tensorflow.framework.optimizers.GradientDescent;
import org.tensorflow.framework.optimizers.Optimizer;
import org.tensorflow.ndarray.Shape;
@Craigacp
Craigacp / onnxruntime-cmake.patch
Created April 23, 2020 16:43
onnxruntime macOS OpenMP patch
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 55519e5a2..3427dd6e5 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -145,6 +145,10 @@ if(onnxruntime_USE_OPENMP)
if(onnxruntime_USE_NGRAPH)
message(FATAL_ERROR "Please use only one of onnxruntime_USE_NGRAPH, onnxruntime_USE_OPENMP")
endif()
+ if (APPLE)
+ include_directories("/usr/local/include")
@Craigacp
Craigacp / CMIMScores.m
Created October 21, 2016 01:55
A demo version of CMIM which returns the feature scores as well as the selected features.
function [selectedFeatures scores] = CMIMScores(k, featureMatrix, classColumn)
%function [selectedFeatures scores] = CMIMScores(k, featureMatrix, classColumn)
%Computes conditional mutual information maximisation algorithm from
%"Fast Binary Feature Selection with Conditional Mutual Information"
%by F. Fleuret (2004)
%Computes the top k features from
%a dataset featureMatrix with n training examples and m features
%with the classes held in classColumn.