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 |
This file contains 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
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(); |
This file contains 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
// 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))) |
This file contains 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
// 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))) |
This file contains 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 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") |
This file contains 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 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") |
This file contains 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/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); |
This file contains 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
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) |
This file contains 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 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 |