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
//Warning: Uses Akka internal APIs (not binary compatible), | |
//can be written not to depend on that but implemented like this for brevity. | |
package akka.util | |
trait CallbackExecutionContext { this: akka.actor.Actor ⇒ | |
// Defines our signal for callback execution | |
case object Execute | |
// ``SerializedSuspendableExecutionContext`` is Akka-internal | |
private[this] final val ssec: SerializedSuspendableExecutionContext = { |
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 scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext | |
import scala.concurrent.Future | |
import akka.pattern.after | |
import akka.actor.Scheduler | |
/** | |
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown, | |
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through | |
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure. |
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
0xb7BfB0d9c2c93a22FE911f871B0D9e4160FDCafE |
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
0xE0Bfce34f6e43b54D7C68dEc29675A92c60ECb6E |
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
## Java | |
sudo apt-get update | |
sudo apt-get install default-jdk | |
## Scala | |
sudo apt-get remove scala-library scala | |
sudo wget https://downloads.lightbend.com/scala/2.12.3/scala-2.12.3.deb | |
sudo dpkg -i scala-2.12.3.deb | |
sudo apt-get update | |
sudo apt-get install scala |
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
def conv2[A: ClassTag](input: Vector[A], kernel: Vector[A], padding: Int, stride: Int)(implicit ev: Numeric[A]) = { | |
// Static sizes | |
val inputHW = sqrt(input.length).toInt | |
val kernelHW = sqrt(kernel.length).toInt | |
val rowSizeAfterPad = inputHW + kernelHW - 1 | |
val rowSizeStrided = rowSizeAfterPad + stride | |
val opsPerPass = rowSizeAfterPad / kernelHW | |
val passSize = kernelHW * rowSizeStrided | |
val inputSizePaddedStrided = (rowSizeStrided * inputHW) + (rowSizeStrided * 2) |
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
trait NArray[I, A] { self => | |
def dims: List[Idx[I]] | |
def coords: data.Vector[A] | |
def resetCoords(v: data.Vector[A]): NArray[I, A] = | |
if (coords.dim == v.dim) { | |
new NArray[I, A] { | |
val dims = self.dims | |
val coords = v |
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 org.deeplearning4j.nn.api.OptimizationAlgorithm | |
import org.deeplearning4j.nn.conf._ | |
import org.deeplearning4j.nn.conf.graph.MergeVertex | |
import org.deeplearning4j.nn.conf.layers._ | |
import org.deeplearning4j.nn.weights.WeightInit | |
import org.nd4j.linalg.lossfunctions.LossFunctions | |
/** | |
* GoogLeNet: https://arxiv.org/abs/1409.4842 | |
*/ |
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 tensorflow.models.embedding.word2vec_optimized import FLAGS, Options, Word2Vec | |
FLAGS1 = FLAGS | |
FLAGS2 = FLAGS | |
class MyOptions(Options): | |
def __init__(self): | |
super(MyOptions, self).__init__() | |
self.train_data = FLAGS1.train_data = "new_train_data" |