ctongfei / nexus

Experimental tensor-typed deep learning
https://tongfei.me/nexus/
MIT License
257 stars 15 forks source link

IndexTensor #32

Open ctongfei opened 5 years ago

ctongfei commented 5 years ago

Amazing idea from @kitsing:

A LongTensor tensor used as an indexer should not be typed as LongTensor[U], instead it should be IndexTensor[U, X <: Dim], where X is the single dimension which it is indexed against. This creates extra typesafety:

oneHot: TI[U, I] => TR[Append[U, I]]
argmax: (T[U], I) => TI[Remove[U, I], I]