Skip to content

Instantly share code, notes, and snippets.

View Orbifold's full-sized avatar
🍀
Happy. Thinking. Understanding.

Francois Vanderseypen Orbifold

🍀
Happy. Thinking. Understanding.
View GitHub Profile
@Orbifold
Orbifold / Keras hello world.md
Created September 1, 2018 06:04
Keras hello world

Using Keras (now part of TensorFlow) is really easy. The complexity comes when you deal with large amounts of data figuring out the topology of a neural network. With the topology comes hyperparameter tuning and all that. It's a bit like painting: it's easy to hold a brush but it takes years to paint something worth looking at.

	import tensorflow as tf
	from tensorflow.keras.models import Sequential
	from tensorflow.keras.layers import Dense
@Orbifold
Orbifold / Gluon hello world.md
Created September 1, 2018 05:49
Gluon hello world
	from mxnet import gluon

	import mxnet as mx
	import numpy as np
	x_input = mx.nd.empty((1, 5), mx.cpu())
	x_input[:] = np.array([[1,2,3,4,5]], np.float32)

	y_input = mx.nd.empty((1, 5), mx.cpu())

y_input[:] = np.array([[10, 15, 20, 22.5, 25]], np.float32)

@Orbifold
Orbifold / TFjsCosine.html
Created August 24, 2018 18:33
Learning the cosine function with TensorFlow.js
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Faker/3.1.0/faker.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
@Orbifold
Orbifold / PyroBasic.ipynb
Created August 23, 2018 17:36
Simplistic example in Pyro.ai.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Orbifold
Orbifold / MxNetLinearRegression.ipynb
Created August 23, 2018 12:36
Linear regression with MXNet.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Orbifold
Orbifold / KerasUnitLearner.py
Created August 23, 2018 12:31
This network learns to map a unit vector to a number corresponding to the position of the '1' in the unit vector.
from keras.layers.core import Dense
from keras.models import Sequential
from numpy import array
import numpy as np
import os
import argparse
from scipy import signal
N = 10
@Orbifold
Orbifold / R_tf_estimator.r
Created August 23, 2018 12:21
R version of TF estimators. See https://tensorflow.rstudio.com.
library(tfestimators)
response <- function() "Species"
features <- function() setdiff(names(iris), response())
# split into train, test datasets
set.seed(123)
partitions <- modelr::resample_partition(iris, c(test = 0.2, train = 0.8))
iris_train <- as.data.frame(partitions$train)
iris_test <- as.data.frame(partitions$test)
@Orbifold
Orbifold / GraphFrames.py
Created August 23, 2018 10:24
Spark GraphFrames.
import pyspark
from pyspark import SparkContext, SparkConf, SQLContext
from pyspark.sql import SparkSession
conf = SparkConf().setMaster("local")
sc = SparkContext(conf=conf)
spark = SparkSession.builder.appName('Noether').getOrCreate()
sc.addPyFile("~/Downloads/graphframes-0.5.0-spark2.1-s_2.11.jar")
@Orbifold
Orbifold / PoorManBlockchain.py
Created August 23, 2018 09:23
Poor man's basic blockchain implementation to grasp the principles.
import hashlib as hasher
import datetime as date
import requests
import time
import math
import uuid
import random