SciSharp / TensorFlow.NET

.NET Standard bindings for Google's TensorFlow for developing, training and deploying Machine Learning models in C# and F#.
https://scisharp.github.io/tensorflow-net-docs
Apache License 2.0
3.2k stars 514 forks source link

feat: add rnn basic modules #1097

Closed AsakusaRinne closed 1 year ago

AsakusaRinne commented 1 year ago
  1. Refactor Tensors to make it support nested structure.
  2. Add Nest<T> and INestStructure<T> to enable better use of nest structures.
  3. Add basic RNN modules.
  4. Revise the implementation of TensorArray.

Note: The ILayer.Call needs to be fully refactored in the future.

@DevNullx64 This PR partially refactors the Tensors, which is mentioned in #1088 . Please feel free to comment anything about that :). Since the target branch is a dev branch, this PR will be merged at once. But if there's disadvantages you catch, we could improve it before merging to master branch.

In this PR the implicit conversion from Tensors to Tensor is still kept because the main purpose of this PR is to support RNN. However I add a check when doing this implicit conversion. If a Tensors has more than one Tensor, then an exception will be thrown. In this way, some error will be visiable.

DevNullx64 commented 1 year ago

Quite not sure, but I think that by adding some class or interface, Nest can hold less. By exemple what is done with the NestType may, prehaps, done by splitting or generic type handling. I seen that "NestType.Node" can't use PackSequenceInternal(). Change class architecture can prehaps avoid possibility to call PackSequenceInternal() from a Nest that should currently have NestType.Node.

I hope to don't borring you to many, I will help you if you want.

After that, you've done a lot of work :) ! I'm loking for this pull.

Ho ! Before I forgot ! Well handling for Tensors to Tensor. it's verry helpfull for debuging :)