etaler / Etaler

A flexable HTM (Hierarchical Temporal Memory) framework with full GPU support.
BSD 3-Clause "New" or "Revised" License
89 stars 14 forks source link

Support solving unknown dimensions in Tensor::reshape() #152

Closed marty1885 closed 4 years ago

marty1885 commented 4 years ago

Now Tensor::reshape() supports unknown dimensions denoted with -1. With basically the same behavior as NumPy.

Ex:

auto a = ones({4, 4});
a = a.reshape({-1, 8}); // Solves as {2, 8} automatically
a = a.reshape({-1, 7}); // Throws. Cannot divide the elements
a = a.reshape({-1, -1, 8}); // Throws. Too many unknown

Like reshape(), resize() also supports solving unknowns.