-
I am going through the examples in chapter 5.1 and coding these in Scala3. I don't seem to understand the First the method name seems to imply that we return several shapes, however we only return one - the last one. Is this correct? Second, the code BTW, with the changes in the latest update the example's TIA. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The getOutputShapes should return what the output NDArray shapes would be, for a given input into your custom Block. It uses an array of shapes as an input and output because blocks use NDLists, not NDArrays. So, each element in the array of shapes is the shape for a different NDArray in the NDList. If you only pass a singleton NDList (as is quite common), you would have arrays containing only one shape. The getOutputShapes is about the block's forward method. Knowing what shapes the forward will input or output is used for both printing blocks and initialization. So, initializeChildBlocks might be using this information to help determine the inputs for various child blocks. Yeah, we added some additional bookkeeping and initialization logic to forward. So, the block implementer will be overriding the forwardInternal which comes after the bookkeeping now |
Beta Was this translation helpful? Give feedback.
The getOutputShapes should return what the output NDArray shapes would be, for a given input into your custom Block. It uses an array of shapes as an input and output because blocks use NDLists, not NDArrays. So, each element in the array of shapes is the shape for a different NDArray in the NDList. If you only pass a singleton NDList (as is quite common), you would have arrays containing only one shape.
The getOutputShapes is about the block's forward method. Knowing what shapes the forward will input or output is used for both printing blocks and initialization. So, initializeChildBlocks might be using this information to help determine the inputs for various child blocks.
Yeah, we adde…