本文整理汇总了Scala中breeze.numerics.exp类的典型用法代码示例。如果您正苦于以下问题:Scala exp类的具体用法?Scala exp怎么用?Scala exp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了exp类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: logistic
//设置package包名称以及导入依赖的类
package classifiers
import breeze.linalg.{*, Axis, DenseMatrix, DenseVector, norm, sum}
import breeze.numerics.exp
def logistic(xTr: DenseMatrix[Double],
yTr: DenseVector[Int]): DenseVector[Double] = {
val doubleYTR = new DenseVector(yTr.toArray.map(_.toDouble))
val YWX = doubleYTR *:* (xTr(*, ::) dot w)
var eToTheYWX = exp.inPlace(YWX)
val numerator = xTr(::, *) *:* doubleYTR
val denominator = eToTheYWX :+= 1.0
val gradient = (sum(numerator(::, *) /:/ denominator, Axis._0) * -1.0).t
reg match {
case Some(reg) => gradient + reg.regGradient(w)
case None => gradient
}
}
}
示例2: BDT
//设置package包名称以及导入依赖的类
package pt1.week6
import breeze.linalg.{DenseMatrix, DenseVector}
import breeze.numerics.exp
object BDT {
def calculateRateLattice(a: DenseVector[Double], b: Double, q: Double, p: Double): DenseMatrix[Double] = {
val n = a.length
val indices = DenseVector((0 until n).map(_.toDouble).toArray)
val result = DenseMatrix.zeros[Double](n, n)
result(0 to 0, 0 to 0) := a(0)
for (i <- 1 until n) {
result(::, i) := exp(indices * b) * a(i)
result(i + 1 until n, i) := 0.00d
}
result
}
}