description: Arbitrary operations from sparse and ragged tensors to a leaf field.
View source on GitHub
|
Arbitrary operations from sparse and ragged tensors to a leaf field.
There are two public methods of note right now: map_sparse_tensor and map_ragged_tensor.
session: {
event: {
val_a: 10
val_b: 1
}
event: {
val_a: 20
val_b: 2
}
event: {
}
event: {
val_a: 40
}
event: {
val_b: 5
}
}
Either of the following alternatives will add val_a and val_b to create val_sum.
map_sparse_tensor converts val_a and val_b to sparse tensors, and then add them to produce val_sum.
new_root = map_prensor.map_sparse_tensor(
expr,
path.Path(["event"]),
[path.Path(["val_a"]), path.Path(["val_b"])],
lambda x,y: x + y,
False,
tf.int32,
"val_sum")
map_ragged_tensor converts val_a and val_b to ragged tensors, and then add them to produce val_sum.
new_root = map_prensor.map_ragged_tensor(
expr,
path.Path(["event"]),
[path.Path(["val_a"]), path.Path(["val_b"])],
lambda x,y: x + y,
False,
tf.int32,
"val_sum")
The result of either is:
session: {
event: {
val_a: 10
val_b: 1
val_sum: 11
}
event: {
val_a: 20
val_b: 2
val_sum: 22
}
event: {
}
event: {
val_a: 40
val_sum: 40
}
event: {
val_b: 5
val_sum: 5
}
}
map_ragged_tensor(...): Map a ragged tensor.
map_sparse_tensor(...): Maps a sparse tensor.
View source on GitHub