Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🍺

Pavel tastyminerals

💭
🍺
  • Gini GmbH
  • Munich, Germany
View GitHub Profile
View numpy_bench.py
import argparse
from collections import defaultdict as dd
from time import perf_counter as timer
import numpy as np
def functions(nruns=1):
rows, cols = 500, 600
reduceRows, reduceCols = rows / 5, cols / 6
@tastyminerals
tastyminerals / julia_bench.jl
Last active Mar 29, 2020
Julia benchmarks
View julia_bench.jl
using BenchmarkTools
using Random
using LinearAlgebra
BenchmarkTools.DEFAULT_PARAMETERS.evals = 20
# define arrays and matrices
rows, cols = 500, 600
reduceRows, reduceCols = Int(rows / 5), Int(cols / 6)
View benchmarks.md
Description NumPy (MKL) (sec.) Julia (sec.)
Dot (scalar) product of two 300000 arrays (float64), (1000 loops) 0.03528142820068751 0.027905 (x1/1.3)
Element-wise sum of two 100x100 matrices (int), (1000 loops) 0.0037877704002312385 0.0061 (x1.6)
Element-wise multiplication of two 100x100 matrices (float64), (1000 loops) 0.004193491550176986 0.032161 (x7.7)
L2 norm of 500x600 matrix (float64), (1000 loops) 0.023907507749936486 0.096 (x4)
Matrix product of 500x600 and 600x500 matrices (float64) 0.0018566828504845035 0.01988 (x10.7)
Sort of 500x600 matrix (float64) **0.0103262
@tastyminerals
tastyminerals / change.d
Created Nov 25, 2019
change-making problem in D (naive implementation)
View change.d
#!/usr/bin/rdmd
import std.algorithm : cartesianProduct;
import std.array;
import std.container.rbtree : redBlackTree;
import std.stdio;
int minimum_coins(int target, in int[] denominations)
{
auto origSet = redBlackTree(target);
View gist:cb2c0bcfa046050c403ba9d2b75f09a9
class NetworkInit(vocabSize: Int) {
private val embeddingWidth = 100
private val hiddenSize = 200
private val numberOfFeats = 9
private val numberOfClasses = 1
val config: ComputationGraphConfiguration = new NeuralNetConfiguration.Builder()
.learningRate(DatasetTools.getTomlConfTable("romain").getDouble("minlr"))
.graphBuilder()
.addInputs("wordIndeces")
View demo
class NetworkInit(vocabSize: Int) {
private val embeddingWidth = DatasetTools.getTomlConfTable("romain").getLong("inputsize").toInt
private val hiddenSize = DatasetTools.getTomlConfTable("romain").getLong("hiddensize").toInt
private val numberOfFeats = DatasetTools.getTomlConfTable("romain").getLong("feats").toInt
private val numberOfClasses = DatasetTools.getTomlConfTable("romain").getLong("classes").toInt
val config: ComputationGraphConfiguration = new NeuralNetConfiguration.Builder()
.learningRate(DatasetTools.getTomlConfTable("romain").getDouble("minlr"))
.graphBuilder()
.addInputs("wordIndeces")
@tastyminerals
tastyminerals / test
Created Jan 30, 2018
MultiDataSetIterator
View test
// init DL4J seq readers
val seqWordsReader = new CSVSequenceRecordReader()
seqWordsReader.initialize(new FileSplit(new File(wordsFileSavePath)))
val seqFeatsReader = new CSVSequenceRecordReader()
seqFeatsReader.initialize(new FileSplit(new File(featsFileSavePath)))
val seqLabelsReader = new CSVSequenceRecordReader()
seqLabelsReader.initialize(new FileSplit(new File(labelsFileSavePath)))
@tastyminerals
tastyminerals / TestMultiIter
Created Jan 29, 2018
Testing DL4J multiiter
View TestMultiIter
// init DL4J seq readers
val seqWordsReader = new CSVSequenceRecordReader()
seqWordsReader.initialize(new FileSplit(new File(wordsFileSavePath)))
val seqFeatsReader = new CSVSequenceRecordReader()
seqFeatsReader.initialize(new FileSplit(new File(featsFileSavePath)))
val seqLabelsReader = new CSVSequenceRecordReader()
seqLabelsReader.initialize(new FileSplit(new File(labelsFileSavePath)))
View gist:6fb19d64c5a48dca967c6c6e6440bb58
MultiDataSetIterator iterator = new RecordReaderMultiDataSetIterator.Builder(batchSize)
.addReader("csvInput", featuresReader)
.addReader("csvLabels", labelsReader)
.addInput("csvInput") //Input: all columns from input reader
.addOutput("csvLabels", 0, 3) //Output 1: columns 0 to 3 inclusive
.addOutputOneHot("csvLabels", 4, numClasses) //Output 2: column 4 -> convert to one-hot for classification
.build();