Skip to content

Instantly share code, notes, and snippets.

Jan Wedekind wedesoft

View GitHub Profile
@wedesoft
wedesoft / mnist.scm
Last active Dec 7, 2018
download and view MNIST data
View mnist.scm
(use-modules (oop goops) (ice-9 binary-ports) (rnrs bytevectors) (aiscm core) (system foreign) (aiscm xorg) (ice-9 format)
; http://yann.lecun.com/exdb/mnist/
(define f (open-file "train-labels-idx1-ubyte" "rb"))
(define magic (bytevector-u32-ref (get-bytevector-n f 4) 0 (endianness big)))
(define n (bytevector-u32-ref (get-bytevector-n f 4) 0 (endianness big)))
(define bv (get-bytevector-n f n))
(define labels (make (multiarray <ubyte> 1) #:memory (bytevector->pointer bv) #:shape (list n)))
(define f (open-file "train-images-idx3-ubyte" "rb"))
(define magic (bytevector-u32-ref (get-bytevector-n f 4) 0 (endianness big)))
@wedesoft
wedesoft / raw-opengl.c
Created Jul 15, 2018
Minimal OpenGL program with texture and shaders
View raw-opengl.c
// Minimal OpenGL shader example using OpenGL directly
#include <math.h>
#include <stdio.h>
#include <GL/glew.h>
#include <GL/glut.h>
const char *vertexSource = "#version 130\n\
in mediump vec3 point;\n\
in mediump vec2 texcoord;\n\
@wedesoft
wedesoft / lstm-predict.py
Last active Nov 6, 2017
Long short-term memory (LSTM) Tensorflow implementation training on Shakespeare's work
View lstm-predict.py
#!/usr/bin/env python3
import sys
import numpy as np
import tensorflow as tf
class CharVec:
def __init__(self, text):
self.chars = np.array([ord(c) for c in sorted(set(text))])
@wedesoft
wedesoft / rnn-predict.py
Last active Nov 6, 2017
Recurrent Neural Network for generating Shakespeare style text
View rnn-predict.py
#!/usr/bin/env python3
import sys
import numpy as np
import tensorflow as tf
class CharVec:
def __init__(self, text):
self.chars = np.array([ord(c) for c in sorted(set(text))])
@wedesoft
wedesoft / autoencoder-run.py
Last active Nov 6, 2017
MNIST autoencoder implemented using Tensorflow
View autoencoder-run.py
#!/usr/bin/env python3
# http://blog.aloni.org/posts/backprop-with-tensorflow/
import random
import numpy as np
import tensorflow as tf
import pickle
import gzip
import cv2
@wedesoft
wedesoft / mnist-dream.py
Last active Nov 6, 2017
Tensorflow implementation of Restricted Boltzmann Machine (RBM) applied to MNIST dataset
View mnist-dream.py
#!/usr/bin/env python3
# http://blog.aloni.org/posts/backprop-with-tensorflow/
import random
import pickle
import gzip
import numpy as np
import tensorflow as tf
import cv2
View grid.pov
// calibration grid
@wedesoft
wedesoft / artanis-user-session.scm
Last active Jun 23, 2016
Guile Artanis user session
View artanis-user-session.scm
(use-modules (artanis artanis) (artanis cookie) (artanis utils))
(init-server)
(get "/" #:session 'spawn
(lambda (rc)
(let [(sid (or (cookie-ref (rc-cookie rc) "sid") (:session rc 'spawn)))
(time (strftime "%c" (localtime (current-time))))]
(tpl->response `(html (body (p ,sid) (p ,time)))))))
(run)
@wedesoft
wedesoft / Dockerfile
Last active Jun 26, 2016
Get session key in Guile Artanis
View Dockerfile
# sudo docker build -t wedesoft/aiscm
# sudo docker run --rm -t -i wedesoft/aiscm /bin/bash
# sudo docker run --rm -p 80:80 wedesoft/aiscm
FROM debian:jessie
MAINTAINER Jan Wedekind <jan@wedesoft.de>
ENV ARTANIS_VERSION 0.1.2.1-be890-dirty
ENV SERVER_HOME /srv/artanis-repl
RUN apt-get update && \
@wedesoft
wedesoft / graph-coloring.scm
Last active Jun 20, 2016
Graph coloring using Chaitin's algorithm
View graph-coloring.scm
(use-modules (srfi srfi-1) (srfi srfi-26) (ice-9 curried-definitions))
(define (dot graph colors)
(apply string-append
(append (list "graph g {")
(map (lambda (color) (format #f " ~a [style=filled, fillcolor=~a];" (car color) (cdr color))) colors)
(map (lambda (edge) (format #f " ~a -- ~a;" (car edge) (cdr edge))) graph)
(list " }"))))
(define (graphviz graph colors) (system (format #f "echo '~a' | dot -Tpng | display -" (dot graph colors))))
(define (nodes graph) (delete-duplicates (append (map car graph) (map cdr graph))))
(define ((has-node? node) edge) (or (eq? (car edge) node) (eq? (cdr edge) node)))
You can’t perform that action at this time.