fengfu-chris / caffe-twns

Implementation of Ternary Weight Networks In Caffe
https://arxiv.org/abs/1605.04711
63 stars 23 forks source link

Blob ternarization #6

Open HahTK opened 7 years ago

HahTK commented 7 years ago

In the Blob::TernaryToProto() function we seem to be using 0.5*alpha as delta instead of the actual value of delta. Is there a reason for doing it this way ?

const double data_vec = cpubinary(); for (int i = 0; i < count; i += 16) { unsigned int n = 0; for(int j=0; j<16 && (i+j)<count_; j++){ int b1 = data_vec[i+j] > -0.5alpha ? 1 : 0; int b2 = data_vec[i+j] > 0.5alpha ? 1 : 0; n ^= (b1 << (2j)); n ^= (b2 << (2*j+1)); } proto->add_ternary_data(n); }