Skip to content

Instantly share code, notes, and snippets.

View koen-dejonghe's full-sized avatar

Koen Dejonghe koen-dejonghe

View GitHub Profile
package botkop.sparti.receiver
import com.rabbitmq.client._
import org.apache.spark.Logging
import org.apache.spark.storage.StorageLevel
import org.apache.spark.streaming.StreamingContext
import org.apache.spark.streaming.dstream.ReceiverInputDStream
import org.apache.spark.streaming.receiver.Receiver
import scala.reflect.ClassTag
@koen-dejonghe
koen-dejonghe / LinearIterativeLearning.scala
Last active January 9, 2017 07:00
Toy example from lecture 3 in Geoffrey Hintons' course Neural Networks for Machine Learning
import scala.language.postfixOps
import scala.util.Random
object LinearIterativeLearning extends App {
case class LabeledData(numFish: Int, numChips: Int, numKetchup: Int, price: Double = 0.0)
case class Weights(fish: Double, chips: Double, ketchup: Double)
package botkop.nn.lecture3
import scala.language.postfixOps
import scala.util.Random
object SigmoidIterativeLearning extends App {
case class LabeledData(numFish: Double, numChips: Double, numKetchup: Double, price: Double = 0.0)
case class Weights(fish: Double, chips: Double, ketchup: Double)
val trueWeights = Weights(0.150, 0.050, 0.100)
This file has been truncated, but you can view the full file.
ap Love whof wamp m rove mak waizor in! shenven wor gpear I d selve for trave sp
----
iter 3326900, loss 40.139576923598945
----
ouc
O vow sppa'g nour love?
FhCVaxt let ard tave wak! por uppit. onoum--prroudix.
For tomn olip toor houk on trarid
Are I!
Wort deve wa?!
This file has been truncated, but you can view the full file.
ap Love whof wamp m rove mak waizor in! shenven wor gpear I d selve for trave sp
----
iter 3326900, loss 40.139576923598945
----
ouc
O vow sppa'g nour love?
FhCVaxt let ard tave wak! por uppit. onoum--prroudix.
For tomn olip toor houk on trarid
Are I!
Wort deve wa?!
package scorch
import scorch.autograd._
import botkop.numsca.Tensor
import botkop.{numsca => ns}
import org.scalactic.{Equality, TolerantNumerics}
import org.scalatest.{FlatSpec, Matchers}
class AutoGradSpec extends FlatSpec with Matchers {
@koen-dejonghe
koen-dejonghe / DinosaurIslandCharRnn.scala
Last active February 20, 2018 08:07
Dinosaurus Island -- Character level language model
package scorch.examples
import botkop.numsca.Tensor
import botkop.{numsca => ns}
import scorch.autograd._
import scorch.nn.rnn.RecurrentModule
import scorch.nn.Optimizer
import scala.annotation.tailrec
import scala.io.Source
@koen-dejonghe
koen-dejonghe / NaiveMemoryManagement.scala
Last active May 27, 2018 08:12
Using the JVM's garbage collector to control off heap memory
package jtorch.cpu
import java.util.concurrent.atomic.AtomicLong
import com.typesafe.scalalogging.LazyLogging
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
import scala.language.postfixOps
package org.apache.mxnet
import java.util.concurrent.atomic.AtomicLong
import com.typesafe.scalalogging.LazyLogging
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
import scala.language.postfixOps
val m: Module = new Module() {
val fc = Linear(100, 10)
override def forward(x: Variable): Variable = x ~> fc ~> relu
}