A plugin that enables all other DeepLearning.scala built-in plugins.
A plugin that enables all other DeepLearning.scala built-in plugins.
杨博 (Yang Bo)
When creating a Builtins from Factory,
import com.thoughtworks.feature.Factory val hyperparameters = Factory[plugins.Builtins].newInstance()
and import
anything in implicits,
import hyperparameters.implicits._
then all DeepLearning.scala built-in features should be enabled.
import org.nd4j.linalg.factory.Nd4j import org.nd4j.linalg.api.ndarray.INDArray
val numberOfInputFeatures = 8 val numberOfOutputFeatures = 1 val initialValueOfWeight: INDArray = Nd4j.rand(numberOfInputFeatures, numberOfOutputFeatures) val weight: hyperparameters.INDArrayWeight = hyperparameters.INDArrayWeight(initialValueOfWeight)
Creating neural network layers,
def fullyConnectedLayer(input: INDArray): hyperparameters.INDArrayLayer = {
input dot weight
}
or loss functions:
def hingeLoss(scores: hyperparameters.INDArrayLayer, label: INDArray): hyperparameters.DoubleLayer = { hyperparameters.max(0.0, 1.0 - label * scores).sum }
Training:
import scalaz.std.vector._ import scalaz.concurrent.Task import com.thoughtworks.each.Monadic._
val batchSize = 4 val numberOfIterations = 10 val input = Nd4j.rand(batchSize, numberOfInputFeatures) val label = Nd4j.rand(batchSize, numberOfOutputFeatures)
@monadic[Task] def train: Task[Vector[Double]] = { for (iteration <- (0 until numberOfIterations).toVector) yield { hingeLoss(fullyConnectedLayer(input), label).train.each } }
When the training is done, the loss of the last iteration should be no more than the loss of the first iteration
train.map { lossesByIteration =>
lossesByIteration.last should be <= lossesByIteration.head
}
杨博 (Yang Bo)
xxx
import com.thoughtworks.feature.Factory import com.thoughtworks.deeplearning.plugins._ val hyperparameters = Factory[DoubleTraining with DoubleLayers with DoubleLiterals with ImplicitsSingleton with Operators].newInstance() import hyperparameters.implicits._ val network: hyperparameters.DoubleLayer = (- (6.1f - (- DoubleLayerOps(3.4f)))) network.predict
A DeepLearning.scala plugin that enables train method for neural networks whose loss is a scala.Double.
A DeepLearning.scala plugin that enables train method for neural networks whose loss is a scala.Double.
杨博 (Yang Bo)
杨博 (Yang Bo)
杨博 (Yang Bo)
xxx
import com.thoughtworks.feature.Factory import com.thoughtworks.deeplearning.plugins._ val hyperparameters = Factory[FloatTraining with FloatLayers with FloatLiterals with ImplicitsSingleton with Operators].newInstance() import hyperparameters.implicits._ val network: hyperparameters.FloatLayer = (- (6.1f - (- FloatLayerOps(3.4f)))) network.predict
A DeepLearning.scala plugin that enables train method for neural networks whose loss is a scala.Float.
A DeepLearning.scala plugin that enables train method for neural networks whose loss is a scala.Float.
杨博 (Yang Bo)
杨博 (Yang Bo)
杨博 (Yang Bo)
A DeepLearning.scala plugin that enables train method for neural networks whose loss is a org.nd4j.linalg.api.ndarray.INDArray.
A DeepLearning.scala plugin that enables train method for neural networks whose loss is a org.nd4j.linalg.api.ndarray.INDArray.
杨博 (Yang Bo)
A plugin to create INDArray weight.
A plugin to create INDArray weight.
杨博 (Yang Bo)
A plugin that creates the instance of implicits.
A plugin that logs uncaught exceptions raised from Layer and Weight.
A plugin of definitions of polymorphic operators.
A plugin of definitions of polymorphic operators.
Those functions are implemented in RawFloatLayers, RawDoubleLayers and RawINDArrayLayers.
杨博 (Yang Bo)
杨博 (Yang Bo)
xxx
import com.thoughtworks.feature.Factory import com.thoughtworks.deeplearning.plugins._ val hyperparameters = Factory[DoubleLiterals with DoubleTraining with RawDoubleLayers with ImplicitsSingleton].newInstance() import hyperparameters.implicits._ val network = (- (- (- DoubleLayerOps(3.4f)))) network.predict
杨博 (Yang Bo)
xxx
import com.thoughtworks.feature.Factory import com.thoughtworks.deeplearning.plugins._ val hyperparameters = Factory[FloatLiterals with FloatTraining with RawFloatLayers with ImplicitsSingleton].newInstance() import hyperparameters.implicits._ val network = (- (- (- FloatLayerOps(3.4f)))) network.predict
杨博 (Yang Bo)
A DeepLearning.scala plugin that enables methods defined in DeepLearning.Ops for neural networks.
A DeepLearning.scala plugin that enables methods defined in DeepLearning.Ops for neural networks.
杨博 (Yang Bo)
杨博 (Yang Bo)
Author:
杨博 (Yang Bo)