All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.thoughtworks.deeplearning.double.layers.LessThan.scala Maven / Gradle / Ivy

The newest version!
package com.thoughtworks.deeplearning
package double.layers

import cats._
import cats.implicits._
import com.thoughtworks.deeplearning.BufferedLayer
import com.thoughtworks.deeplearning.boolean.utilities.BooleanMonoidBatch

/**
  * @author 杨博 (Yang Bo) <[email protected]>
  */
final case class LessThan[Input0 <: Batch](
    operand1: Layer.Aux[Input0, Batch.Aux[Eval[scala.Double], Eval[scala.Double]]],
    operand2: Layer.Aux[Input0, Batch.Aux[Eval[scala.Double], Eval[scala.Double]]]
) extends BufferedLayer.Binary {

  type BufferedBatch = BooleanMonoidBatch with MonoidBatch with BinaryBatch

  type Input = Input0

  override protected def rawForward(input0: Input): BufferedBatch = {
    new {
      override final val input = input0
    } with BooleanMonoidBatch with MonoidBatch with BinaryBatch {
      override val value = upstream1.value.map2(upstream2.value)(_ < _).memoize

      override protected def rawBackward(delta: Eval[scala.Boolean]): Unit = {
        upstream1.backward(Eval.now(0.0))
        upstream2.backward(Eval.now(0.0))
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy