Description
The Tensors class implements an implicit cast to Tensor. It simply returns the first Tensor in its list. There is a potential risk of information loss in this case. While casting from float to double does not pose any problems, casting from double to float requires an explicit conversion.
Alternatives
I looked into the impact of an explicit cast. I made the necessary corrections to pass the tests. However, I had to modify the unit tests to ensure proper casting of Tensors. It doesn't feel clean to do that...
I went a bit further and realized that almost all implementations of the layers use a Tensor as input and output. I got overwhelmed by the task of revising everything quickly. Then, I reached the RNN section, which seems to be under development. At that point, I couldn't make the necessary corrections or add a comment to guide the changes. I gave up on completing the task when I realized the extent of the impact. I was in the process of making a modification that would affect everything derived from Loss or Layer, and with generics (to avoid having to declare typed arguments and hiding inherited members, etc.).
Description
The Tensors class implements an implicit cast to Tensor. It simply returns the first Tensor in its list. There is a potential risk of information loss in this case. While casting from float to double does not pose any problems, casting from double to float requires an explicit conversion.
Alternatives
I looked into the impact of an explicit cast. I made the necessary corrections to pass the tests. However, I had to modify the unit tests to ensure proper casting of Tensors. It doesn't feel clean to do that...
I went a bit further and realized that almost all implementations of the layers use a Tensor as input and output. I got overwhelmed by the task of revising everything quickly. Then, I reached the RNN section, which seems to be under development. At that point, I couldn't make the necessary corrections or add a comment to guide the changes. I gave up on completing the task when I realized the extent of the impact. I was in the process of making a modification that would affect everything derived from Loss or Layer, and with generics (to avoid having to declare typed arguments and hiding inherited members, etc.).