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
# This script illustrates how to apply a trained image classifier to a new set | |
# of images. | |
# Author: Mick Thomure | |
# Date: 12/29/2013 | |
from glimpse.experiment import * | |
from glimpse.pools import * | |
def PredictImageClasses(exp, images, pool): | |
"""Apply existing model to a new set of images. |
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
from glimpse.experiment import * | |
def make_model_for_protos(protos): | |
"""Create a model for an existing set of prototypes.""" | |
model = Model() | |
# Here, we assume that all prototypes have the same spatial extent. | |
model.s2_kernels = [protos] | |
return model | |
def train_classifier(model, pool, images, labels): |
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
from cPickle import load as load_pickle | |
from glimpse.experiment import Layer, ExtractFeatures, GetTrainingSet | |
# load an experiment object from disk, as saved by the 'glab' command. | |
def load_experiment(path): | |
with open(path) as f: | |
# load saved experiment. return type is described here: | |
# https://github.com/mthomure/glimpse-project/blob/master/glimpse/experiment/experiment.py#L77 | |
return load_pickle(f) |
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
(ns hello-quil.noisy-spirals | |
(:require [quil.core :as q] | |
[hello-quil.noisy-spirals-dynamic :as d] | |
[clojure.core.async :as a] | |
[overtone.midi :as midi] | |
[mojion.leap :as leap])) | |
(q/defsketch gen-art-14 | |
:title "100 Noisy Spirals" | |
:size [d/SIZE d/SIZE] |
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
(ns fuzzy-diff | |
"Approximate comparison of floating-point numbers for clojure.data/diff." | |
(:require [clojure.data :refer [Diff]])) | |
(def ^:dynamic *fuzz* 0) | |
(defn fuzzy-float-diff [a b] | |
(if (< (Math/abs (- a b)) *fuzz*) [nil nil a] [a b nil])) | |
(extend java.lang.Double |
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
(ns getpid | |
(:import [jnr.ffi.types pid_t] | |
[jnr.ffi LibraryLoader])) | |
;; see https://github.com/jnr/jnr-ffi-examples/blob/master/getpid/src/main/java/getpid/Getpid.java | |
;; using dependency: [com.github.jnr/jnr-ffi "2.0.9"] | |
;; public interface LibC { | |
;; public @pid_t long getpid(); | |
;; public @pid_t long getppid(); |
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
#include "lbfgs.h" // see https://github.com/stephenbeckr/L-BFGS-B-C/blob/master/src/lbfgsb.h | |
#include <stdio.h> | |
int test_setulb(integer *n, integer *m, double *x, double *l, | |
double *u, integer *nbd, double *f, | |
double *g, double *factr, double *pgtol, double *wa, | |
integer *iwa, integer *task, | |
integer *iprint, integer *csave, | |
logical *lsave, integer *isave, double *dsave) { | |
printf("test_setulb()\n"); |
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
;; Port of https://github.com/bytedeco/javacpp-presets/tree/master/openblas | |
;; Requires openblas dependency: | |
;; [org.bytedeco.javacpp-presets/openblas-platform "0.2.19-1.3"] | |
(ns ExampleDGELSrowmajor | |
(:import [org.bytedeco.javacpp openblas])) | |
(defn print-matrix-rowmajor [desc m n mat ldm] | |
(println "\n " desc) | |
(doseq [i (range m)] | |
(doseq [j (range n)] |
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
(ns read-excel-stream | |
(:import [com.monitorjbl.xlsx StreamingReader])) | |
;; Remember to add the following maven dependency: | |
;; [com.monitorjbl/xlsx-streamer "1.0.1"] | |
;; More info here: | |
;; https://github.com/monitorjbl/excel-streaming-reader | |
(defn workbook | |
"Open an Excel workbook, for example in a with-open form. This is lazy, and |
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
(ns hdf5 | |
(:import [org.bytedeco.javacpp | |
DoublePointer FloatPointer | |
LongPointer IntPointer | |
ShortPointer BytePointer] | |
[org.bytedeco.javacpp hdf5 hdf5$H5File])) | |
;; Using maven dependency: | |
;; [org.bytedeco.javacpp-presets/hdf5-platform "1.10.0-patch1-1.3"] |
OlderNewer