Пример #1
0
void DenseMat<CPU, Dtype>::Softmax()
{
    	Dtype sum, max_v;
		size_t i, j;
        Dtype* data_ptr;
        for (i = 0, data_ptr = this->data; i < this->rows; ++i, data_ptr += this->cols)
        {
            max_v = data_ptr[0];
            for (j = 1; j < this->cols; ++j)
                if (data_ptr[j] > max_v)
                    max_v = data_ptr[j];
            for (j = 0; j < this->cols; ++j)    
                data_ptr[j] -= max_v;
        }
        
        MKLHelper_Exp(this->count, this->data, this->data);
        for (i = 0, data_ptr = this->data; i < this->rows; ++i, data_ptr += this->cols)
        {
            sum = MKLHelper_Asum(this->cols, data_ptr);
            for (j = 0; j < this->cols; ++j)
                data_ptr[j] /= sum;
        }
}
Пример #2
0
Dtype DenseMat<CPU, Dtype>::Asum()
{
	return MKLHelper_Asum(this->count, data);
}
Пример #3
0
Dtype SparseMat<CPU, Dtype>::Asum()
{
    return MKLHelper_Asum(data->nnz, data->val);
}