fold
fold copied to clipboard
How to use sequence of tuples
I can find anything in the API for handling sequences of tuples. After executing the block below, I want to be able to manipulate each tuple. For example, input_block outputs:
[([array(1.0, dtype=float32), array(2.0, dtype=float32), array(4.0, dtype=float32)], array(0.0, dtype=float32)),...]
and I'm trying to figure out how to take the firs tuple and create several td.Vector(3)s with 0.0 in the second index like so [1.0, 0.0, 2,0], [2.0, 0.0, 4.0], [1.0,0.0,4.0]
. How can you achieve this with Fold?
# tree input
test_input = [
{'node':0, 'neighbors':[1,2,4]},
{'node':1, 'neighbors':[6,3,0]},
{'node':2, 'neighbors':[0]},
{'node':3, 'neighbors':[1,5]},
{'node':4, 'neighbors':[0]},
{'node':5, 'neighbors':[3]},
{'node':6, 'neighbors':[1]}
]
input_block = td.Map(td.Record({'node':td.Scalar(), 'neighbors':td.Map(td.Scalar())}))
print input_block.eval(test_input)
I'm afraid I don't really understand your explanation of what you were trying to do. There are no tuples in your input -- just records and lists. The 'neighbors' field doesn't contain tuples (which must be of fixed length) it contains lists (sequences) of varying length.
As you seem to be aware, your options for processing lists are via Map, Zip, Reduce, Fold, and RNN.
On Wed, May 3, 2017 at 7:28 AM, Justin Chen [email protected] wrote:
I can find anything in the API for handling sequences of tuples. After executing the block below, I want to be able to manipulate each tuple. For example, input_block outputs: [([array(1.0, dtype=float32), array(2.0, dtype=float32), array(4.0, dtype=float32)], array(0.0, dtype=float32)),...] and I'm trying to figure out how to take the firs tuple and create several td.Vector(3)s with 0.0 in the second index like so [1.0, 0.0, 2,0], [2.0, 0.0, 4.0], [1.0,0.0,4.0]. How can you achieve this with Fold?
tree input
test_input = [ {'node':0, 'neighbors':[1,2,4]}, {'node':1, 'neighbors':[6,3,0]}, {'node':2, 'neighbors':[0]}, {'node':3, 'neighbors':[1,5]}, {'node':4, 'neighbors':[0]}, {'node':5, 'neighbors':[3]}, {'node':6, 'neighbors':[1]} ] input_block = td.Map(td.Record({'node':td.Scalar(), 'neighbors':td.Map(td.Scalar())})) print (input_block >> td.Reduce(td.ScopedLayer(conv_layer))).eval(test_input)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tensorflow/fold/issues/55, or mute the thread https://github.com/notifications/unsubscribe-auth/AGGbTeLcveA7g6V2H6OeNFNCqeI0Xw3Wks5r2I8LgaJpZM4NPe1Z .
-- DeLesley Hutchins | Software Engineer | [email protected] | 505-206-0315