Skip to content

Instantly share code, notes, and snippets.

Avatar

Roman Zykov rzykov

View GitHub Profile
@rzykov
rzykov / Nd4j_lstm.scala
Created Aug 21, 2017 — forked from harperjiang/Nd4j_lstm.scala
Performance comparison of numpy vs nd4j on LSTM implementation
View Nd4j_lstm.scala
import org.nd4j.linalg.api.ndarray.INDArray
import org.nd4j.linalg.api.ops.impl.broadcast.BroadcastAddOp
import org.nd4j.linalg.api.rng.distribution.impl.UniformDistribution
import org.nd4j.linalg.factory.Nd4j
import scala.util.Random
object Xavier {
def init(shape: Array[Int]): INDArray = {
var n = shape.dropRight(1).product
View gist:d5aa7e065203a2a7221ce1bbf663f511
package org.deeplearning4j.learn
import java.util.Arrays
import org.nd4j.api.linalg.DSL._
import org.nd4j.linalg.api.ndarray.INDArray
import org.nd4j.linalg.factory.Nd4j
import org.nd4j.linalg.indexing.{NDArrayIndex, BooleanIndexing}
import org.nd4j.linalg.indexing.conditions.Conditions
import org.nd4j.linalg.indexing.functions.Value
@rzykov
rzykov / XgBoostRankSparkScala.scala
Last active Dec 21, 2020
XGboost Spark - ranking problem
View XgBoostRankSparkScala.scala
import _root_.ml.dmlc.xgboost4j.scala.spark.XGBoost
import org.apache.spark.ml.feature.LabeledPoint
def encodeFeaturesToLabeledPoint(features: RDD[Feature], relevance: Option[RDD[Relevance]], workers: Int)
(implicit parallel: Int): (RDD[LabeledPoint], Seq[String], Seq[Seq[Int]]) = {
val missingValue = Double.NaN
val names = features
.map { _.name }