GithubHelp home page GithubHelp logo

ofnote / tsalib Goto Github PK

View Code? Open in Web Editor NEW
256.0 256.0 14.0 216 KB

Tensor Shape Annotation Library (numpy, tensorflow, pytorch, ...)

License: Apache License 2.0

Python 85.21% Jupyter Notebook 14.79%
deep-learning keras numpy pytorch tensor-shape tensorflow

tsalib's People

Contributors

ekshaks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tsalib's Issues

Use with Pandas

Does it make sense to use tsalib for Pandas series and/or dataframes?

Wrong dimension in the documentation?

This is a great library! I am wondering whether 'b,1,d' should be 'b,l,d' in the following assignment that I found in README.md:
b: 'b,1,d' = alignto((a,'bd'), 'bld')

Is requirements.txt needed?

There is already a setup.py file which defines the requirements. tsalib probably doesn't need a requirements.txt file since it's not used as a standalone application.

Include `alignto` as an operator inside `warp`

Old:

x = np.random.randn(10,50,300)
x = x[None, None, None, :].permute(3, 0, 1, 2)

New:

from tsalib import dim_vars, get_dim_vars, alignto, warp
# B, T, D, C = dim_vars('B(b):10 T(t):50 D(d):300 C(c):4') #one time, in __main__

B, T, D, C = get_dim_vars('b t d c')
x: 'btd' = np.random.randn(B,T,D)
x = alignto((x, 'btd'), 'btdc')
x = warp(x, 'btdc -> cbtd', 'p') #'p' for permute

combine last two lines as:

x = warp(x, 'btd -> btdc -> cbtd', 'ap') #'a' for align

Is code in openai_transformer.py runnable?

Hi,

I'm trying to instantiate OpenaiTransformer class from openai_transformer.py code in transformer toy problem setting to learn your tsalib a bit. I'm curious to learn how useful tensor shape annotations would be in practice.

However, I've noticed some syntax level errors in code, e.g.:

  1. in Conv1D.forward() body there is self.nx attribute referenced that is not defined.
  2. is "def forward(self, x: (B, T, self.nx)) -> torch.Tensor:" syntax valid? It causes a crash
  3. Attention.forward(self, x: (B, T, self.nx)) -> torch.Tensor: causes a crash "NameError: name 'self' is not defined"
  4. no TransformerConfig class in source file
  5. in class OpenaiTransformer.forward(self, x: (B,T)) -> List[B, T, D]:" last part "[B, T, D]" causes a crash "TypeError: Parameters to generic types must be types. Got Batch."

How would you go about correcting these problems?

Best,
Wojtek

Guess transformation type in `warp`

  • user only specifies the shape transformation sequence
  • guess 'v' or 'p' or 'e' or 'c' (restricted to patterns over these shorthands?)
  • throw error if none of the above transforms.

Updating DimVar's value best practice

So I'm declaring global DimVars (without a hardcoded value) and later at runtime want to update their values based on some hyperparams to do shape assertions.
I'm aware I can just manipulate their ._val propery, but that seems a bit hacky to me, what's the intended workflow for this kind of problem?

Include `join` spec in `warp`

Right now join spec consists of a single shape annotation with * or ^

Allow join spec to be in l -> r form, e.g. (b,t,d)* -> (^,b,t,d). Then, a warp sequence can contain a join.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.