Hi,

I'm currently trying to implement the method in the paper "
Compressing Neural Networks with the Hashing Trick 
<https://arxiv.org/pdf/1504.04788>
"
The idea is very simple. I just get stuck how to aggregate the elements in 
the 4D tensor quickly. Each element in the 4D tensor is mapped to a bucket 
in a low-dimensional vector, and elements mapped to the same bucket needs 
to be added up together. Currently, I just use a 'map' function to 
implement this, and at each iteration, I add the element in the 4D tensor 
in the corresponding bucket. But it is extremely slow. 
'gp_value' is the 4D value of the tensor. idxW stores the bucket ID of the 
low dimensional vector. 'grad_h_weight' is the vector. 

def fn_reduce(cur_grad,index):
    return {grad_h_weight: T.inc_subtensor(grad_h_weight[index],
                                                          cur_grad)}
_, updates = theano.map(fn_reduce,
         
sequences=[theano.shared(np.asarray(gp_value,dtype='float32'),borrow=True).flatten(),
                        idxW])


cal = theano.function([],updates=updates)
cal()


Any one can help? 


Thanks very much. 





-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to