That is to say, it may raise error when using functions in tensorflow and pytorch just as how they are used in numpy. The fact in this short post (the same API can behave differently in many ways between the three libraries) reminds us to read the corresponding documentations carefully and don’t take it for granted that the similar API should behave the same. Especially when, more or less, tensorflow and pytorch have given some promise on the consitent interface with numpy in terms of linear algebra operations. It is rather amazing to see that there are so many subtle differences between the similar APIs in these three libraries. For example, the returned s are all represented in a vector form of singular values instead of the S matrix itself in SVD decomposition. The code below is showing 3 types of python SVD. The three methods of course share some similarity. Using SVD, we are able to represent our large matrix A by 3 smaller. Another side note: in old version of pytorch, SVD API doesn’t support broadcasting mechanism, this is fixed in recent version of torch, at least for pytorch 1.3.1.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |