Thanks Barry.

In my experiment, it doesn't affect kbmira.
Seemingly ToSparse is only called by hypergraph mira.

Cheers
Liangyou


On Fri, Mar 13, 2015 at 4:09 PM, Barry Haddow <[email protected]>
wrote:

> Hi Liangyou
>
> I looked into this a bit, and I think that ToSparse() should indeed be
> fixed along the lines you suggest. This would mean that hypergraph mira is
> currently broken for sparse features, although I don't think kbmira is
> affected.
>
> I'm quite busy at the moment, but I'll do some more testing and check in a
> fix as soon as I can - in the next week or two,
>
> 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.
>
>


-- 

Liangyou Li
CNGL
School of Computing
Dublin City University
_______________________________________________
Moses-support mailing list
[email protected]
http://mailman.mit.edu/mailman/listinfo/moses-support

Reply via email to