<commit_before>package BIDMach

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


class LDAModel(override val opts:LDAModel.Options = new LDAModel.Options) extends FactorModel(opts) { 
  var mm:Mat = null
  var alpha:Mat = null
  
  var traceMem = true
  
  override def init(datasource:DataSource) = {
    super.init(datasource)
    updatemats = new Array[Mat](1)
    mm = modelmats(0)
    updatemats(0) = mm.zeros(mm.nrows, mm.ncols)
  }
  
  def uupdate(sdata:Mat, user:Mat):Unit = {
    if (opts.putBack < 0) user.set(1f)
	  for (i <- 0 until opts.uiter) {
	  	val preds = DDS(mm, user, sdata)	
	  	if (traceMem) println("uupdate %d %d %d, %d %f %d" format (mm.GUID, user.GUID, sdata.GUID, preds.GUID, GPUmem._1, getGPU))
	  	val dc = sdata.contents
	  	val pc = preds.contents
	  	println("uupdate1 %d %d %d %d %d" format (sdata.nnz, preds.nnz, dc.nrows, pc.nrows, getGPU))
	  	max(opts.weps, pc, pc)
	  	pc ~ dc / pc
	  	println("uupdate2 %d %d %d %d %d" format (sdata.nnz, preds.nnz, dc.nrows, pc.nrows, getGPU))
	  	val unew = user *@ (mm * preds) + opts.alpha
/*	  	val unew1 = mm * preds
	  	val unew = user *@ unew1
	  	unew ~ unew + opts.alpha */
	  	if (traceMem) println("uupdate %d %d %d, %d %d %d %d %f %d" format (mm.GUID, user.GUID, sdata.GUID, preds.GUID, dc.GUID, pc.GUID, unew.GUID, GPUmem._1, getGPU))<commit_msg>fixing MT<commit_after>package BIDMach

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


class LDAModel(override val opts:LDAModel.Options = new LDAModel.Options) extends FactorModel(opts) { 
  var mm:Mat = null
  var alpha:Mat = null
  
  var traceMem = false
  
  override def init(datasource:DataSource) = {
    super.init(datasource)
    updatemats = new Array[Mat](1)
    mm = modelmats(0)
    updatemats(0) = mm.zeros(mm.nrows, mm.ncols)
  }
  
  def uupdate(sdata:Mat, user:Mat):Unit = {
    if (opts.putBack < 0) user.set(1f)
	  for (i <- 0 until opts.uiter) {
	  	val preds = DDS(mm, user, sdata)	
	  	if (traceMem) println("uupdate %d %d %d, %d %f %d" format (mm.GUID, user.GUID, sdata.GUID, preds.GUID, GPUmem._1, getGPU))
	  	val dc = sdata.contents
	  	val pc = preds.contents
//	  	println("uupdate1 %d %d %d %d %d" format (sdata.nnz, preds.nnz, dc.nrows, pc.nrows, getGPU))
	  	max(opts.weps, pc, pc)
	  	pc ~ dc / pc
//	  	println("uupdate2 %d %d %d %d %d" format (sdata.nnz, preds.nnz, dc.nrows, pc.nrows, getGPU))
	  	val unew = user *@ (mm * preds) + opts.alpha
/*	  	val unew1 = mm * preds
	  	val unew = user *@ unew1
	  	unew ~ unew + opts.alpha */
	  	if (traceMem) println("uupdate %d %d %d, %d %d %d %d %f %d" format (mm.GUID, user.GUID, sdata.GUID, preds.GUID, dc.GUID, pc.GUID, unew.GUID, GPUmem._1, getGPU))
{'fraction_non_alphanumeric': 0.15244116613979627, 'fraction_numerical': 0.008429926238145416, 'mean_word_length': 3.3950617283950617, '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': '6426308', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1232, 'n_words': 290}