Comments (5)
The intention of the code makes sense, however according to the current semantics of Vector
the operation seems weird because v
has shape (15,)
but the after the norm per leaf it has shape (2,)
, and division between such vectors would make no sense.
Maybe we need a looser abstraction (e.g. Numeric
) that just lets you do leaf wise math operations but doesn't have array-like semantics.
from tree-math.
I think I see. I was somehow expecting Vector
to allow leaf-wise math. The abstraction you suggest could be nice to avoid tree_map
calls in general. For the above example, having something like
normalized_tree = tree / tm.norm(tree)
, with tree
an instance of Numeric
may be ideal. One example use-case is implementing power iteration with a pytree input.
from tree-math.
Leaf-wise math sounds potentially useful but as @cgarciae notes it's definitely a different data model. I would love to see a more fully fleshed out use-case for this functionality.
from tree-math.
Since a lot of the operations from Vector
are also leaf-wise there is the possibility that Numeric
/ NumericMixin
might serve as a base class to Vector
and friends. One of the big differences with Vector
would be the dot
method, it would either have to also be leaf-wise and return a pytree or just not included as an operation.
from tree-math.
My mental model for objects like this is that they are something closer to ragged arrays, e.g., a 2D matrix where the first dimension corresponds to the number of pytree leaves, and the second dimension corresponds to the (variable) size of each leaf.
from tree-math.
Related Issues (11)
- How well does tree-math support computation on multiple devices? HOT 1
- import struct HOT 1
- Unexpected input type for array? HOT 2
- `tm.unwrap`: Error when `out_vectors` is list [documentation] HOT 1
- New release? HOT 1
- support static fields in treemath.struct HOT 1
- VectorMixin HOT 5
- Rename wrap/unwrap? HOT 2
- Matrix support HOT 6
- Transform for defining dataclasses with VectorMixin like flax.struct HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tree-math.