Ugur Koc
2018-06-12 21:58:46 UTC
Hi,
I am a newbie for theano. I am trying to store symbolic keys and values
into a python OrderedDict as follows;
hmap=OrderedDict()
key = T.vector('key', dtype='int64')
val = T.scalar('val', dtype='int64')
minus_one=T.constant(-1, dtype='int64')
def read_map(key_):
return hmap.get(key_, minus_one)
def update_map(key_, val_):
hmap[key_]=val_
return hmap[key_]
read_map_result, _ = theano.scan(fn=read_map, sequences=[key],
outputs_info=None)
read_map_f = theano.function(inputs=[key], outputs=read_map_result)
update_map_result, updates = theano.scan(fn=update_map, sequences = [key],
non_sequences=val, outputs_info=None)
update_map_f = theano.function(inputs=[key, val],
outputs=update_map_result, updates=updates)
print(update_map_f([0, 1, 2], 5))
print(read_map_f([2]))
print(hmap)
Giving this output;
[5 5 5]
[-1]
OrderedDict([(key[t], val)])
So lookup for key 2 fails with `read_map_f`.
Any easy solution to this?
Thanks!
I am a newbie for theano. I am trying to store symbolic keys and values
into a python OrderedDict as follows;
hmap=OrderedDict()
key = T.vector('key', dtype='int64')
val = T.scalar('val', dtype='int64')
minus_one=T.constant(-1, dtype='int64')
def read_map(key_):
return hmap.get(key_, minus_one)
def update_map(key_, val_):
hmap[key_]=val_
return hmap[key_]
read_map_result, _ = theano.scan(fn=read_map, sequences=[key],
outputs_info=None)
read_map_f = theano.function(inputs=[key], outputs=read_map_result)
update_map_result, updates = theano.scan(fn=update_map, sequences = [key],
non_sequences=val, outputs_info=None)
update_map_f = theano.function(inputs=[key, val],
outputs=update_map_result, updates=updates)
print(update_map_f([0, 1, 2], 5))
print(read_map_f([2]))
print(hmap)
Giving this output;
[5 5 5]
[-1]
OrderedDict([(key[t], val)])
So lookup for key 2 fails with `read_map_f`.
Any easy solution to this?
Thanks!
--
---
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 theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
---
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 theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.