Beispiel #1
0
//update all rows of Z^t
void M3LLinear::update_all_rows( SparseVector& x, const M3LFloat* Rrow, const M3LFloat& scale)
{
	
	
	M3LFloat* Zk=Z;
	M3LFloat mk;
	int nnz=x.get_nnz();
	for(int k=0;k<L;k++)
	{
		
		if(Rrow[k]==0)
		{
			Zk+=d;
			continue;
		}
		mk=Rrow[k]*scale;
		for(int i=0;i<nnz;i++)
		{
			Zk[x.get_ith_index(i)]+=mk*(x.get_ith_value(i));
		}
		b[k]+=Rrow[k]*scale*bias;	
		Zk+=d;
	}
	
}
Beispiel #2
0
//helper functions
void add(M3LFloat* s, SparseVector a, M3LFloat scale)
{
	
	int nnz=a.get_nnz();
	for(int i=0;i<nnz;i++)
	{
		s[a.get_ith_index(i)]+=scale*(a.get_ith_value(i));
	}
}
Beispiel #3
0
//update only current row of Z^t
void M3LLinear::update_current_row(const int& l, SparseVector& x, const M3LFloat& scale)
{
	M3LFloat* Zl=getZrow(l);
	int nnz=x.get_nnz();
	for(int i=0;i<nnz;i++)
	{
		Zl[x.get_ith_index(i)]+=scale*(x.get_ith_value(i));
	}
	b[l]+=scale*bias;
}
Beispiel #4
0
M3LFloat M3LLinear::score(const int& l, SparseVector& x)
{
	M3LFloat* Zl=getZrow(l);
	int nnz=x.get_nnz();
	M3LFloat sum=0;
	
	for(int i=0;i<nnz;i++)
	{
		sum+=Zl[x.get_ith_index(i)]*x.get_ith_value(i);
		
	}
	sum+=bias*b[l];
	
	return sum;
}