<commit_before>package BIDMach
import BIDMat.{Mat,BMat,CMat,DMat,FMat,IMat,HMat,GMat,GIMat,GSMat,SMat,SDMat}
import BIDMat.MatFunctions._
import BIDMat.SciFunctions._

abstract class Regularizer(opts:Regularizer.Options = new Regularizer.Options) { 
  val options = opts
  
  def compute(modelmats:Array[Mat], updatemats:Array[Mat], step:Float)
  
  def initregularizer = {
  }
}

class L1Regularizer(opts:Regularizer.Options = new Regularizer.Options) extends Regularizer(opts) { 
   def compute(modelmats:Array[Mat], updatemats:Array[Mat], step:Float) = {
     for (i <- 0 until modelmats.length) {
       updatemats(i) ~ updatemats(i) + (sign(modelmats(i)) * (-step*options.mprior)) 
     }
   }
}

class L2Regularizer(opts:Regularizer.Options = new Regularizer.Options) extends Regularizer(opts) { 
   def compute(modelmats:Array[Mat], updatemats:Array[Mat], step:Float) = {
  	 for (i <- 0 until modelmats.length) {
  		 updatemats(i) ~ updatemats(i) + (modelmats(i) * (-options.mprior * step))
  	 }
   }
}

object Regularizer {
  class Options {
    var mprior:Float = 1e-7f }
}<commit_msg>added DataSource<commit_after>package BIDMach
import BIDMat.{Mat,BMat,CMat,DMat,FMat,IMat,HMat,GMat,GIMat,GSMat,SMat,SDMat}
import BIDMat.MatFunctions._
import BIDMat.SciFunctions._

abstract class Regularizer(opts:Regularizer.Options = new Regularizer.Options) { 
  val options = opts
  
  def compute(modelmats:Array[Mat], updatemats:Array[Mat], step:Float)
  
  def initregularizer = {
  }
}

class L1Regularizer(opts:Regularizer.Options = new Regularizer.Options) extends Regularizer(opts) { 
   def compute(modelmats:Array[Mat], updatemats:Array[Mat], step:Float) = {
     for (i <- 0 until modelmats.length) {
       updatemats(i) ~ updatemats(i) + (sign(modelmats(i)) * (-step*options.mprior)) 
     }
   }
}

class L2Regularizer(opts:Regularizer.Options = new Regularizer.Options) extends Regularizer(opts) { 
   def compute(modelmats:Array[Mat], updatemats:Array[Mat], step:Float) = {
  	 for (i <- 0 until modelmats.length) {
  		 updatemats(i) ~ updatemats(i) + (modelmats(i) * (-options.mprior * step))
  	 }
   }
}

object Regularizer {
  class Options {
    var mprior:FMat = 1e-7f }
}
{'fraction_non_alphanumeric': 0.13387978142076504, 'fraction_numerical': 0.00546448087431694, 'mean_word_length': 4.633333333333334, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1873493', 'n_tokens_mistral': 840, 'n_tokens_neox': 798, 'n_words': 137}