Hello, I’m having a problem with managing multiple inputs of nested Gluon’s HybridBlocks. Currently HybridBlock can take as input only Symbols, NDArray and nested lists of them. Lists of inputs are not well manageable when there are multiple nested components. A dictionary passed as input would be better since we have keys instead of raw nd arrays. Do you know some way around this to mange inputs better?
The goal is to have something like this:
class MyBlock(gluon.HybridBlock):
def __init__(self, child_blocks):
self.child_blocks = child_blocks
def hybrid_forward(self, F, input_dict, **kwargs):
for child_block in self.child_blocks:
cur_outputs = child_blocks(input_dict) # child fetches input itself
outputs = self._merge_output(outputs, cur_outputs)
return outputs
instead of this:
class MyBlock(gluon.HybridBlock):
def __init__(self, child_blocks):
self.child_blocks = child_blocks
def hybrid_forward(self, F, *inputs, **kwargs):
for inpt, child_block in zip(inputs, self.child_blocks):
cur_outputs = child_blocks(inpt) # parent block must handle how children handles data
outputs = self._merge_output(outputs, cur_outputs)
return outputs
In essence - can MyBlock be unaware how the children handle own inputs?