Hi Liangyou

This doesn't look right. In fact there is no reason for the gap between 
the indices. Let me look into it,

cheers - Barry

On 06/03/15 15:43, Liangyou Li wrote:
> I have a question about the function :   
> MiraWeightVector.ToSparse(SparseVector* sparse) .
>
> It's defined as this:
>
> void MiraWeightVector::ToSparse(SparseVector* sparse) const
> {
>   for (size_t i = 0; i < m_weights.size(); ++i) {
>     if(abs(m_weights[i])>1e-8) {
> sparse->set(i,m_weights[i]);
>     }
>   }
> }
>
> This means the same index i is used for both SparseVector and 
> MiraWeightVector.
> However, according to the code in kbmira.cpp, there's a gap between 
> the indexes.
>
> for dense feature:      size_t id = SparseVector::encode(names[i]);
> then, for sparse feature:      size_t id = SparseVector::encode(name) 
> + initDenseSize;
>
>
> ​Why isn't  the ToSparse function looks like this:
>
> void MiraWeightVector::ToSparse(SparseVector* sparse, size_t 
> denseSize) const
> {
>   for (size_t i = 0; i < m_weights.size(); ++i) {
>     if (i < denseSize) {
> sparse->set(i,m_weights[i]);
>     } else {
> if(abs(m_weights[i])>1e-8) {
> sparse->set(i-denseSize,m_weights[i]);
>       }
>     }
>   }
> }
>
> I'm kind of confused,  did I miss something ?
> Many thanks.
>
> Liangyou
>
> -- 
>
> Liangyou Li
> CNGL
> School of Computing
> Dublin City University
>
>
>
> _______________________________________________
> Moses-support mailing list
> [email protected]
> http://mailman.mit.edu/mailman/listinfo/moses-support


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

_______________________________________________
Moses-support mailing list
[email protected]
http://mailman.mit.edu/mailman/listinfo/moses-support

Reply via email to