This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for i, (rel_img, rel_qst, rel_label, norel_img, norel_qst, norel_label) in enumerate(dataloader_train): | |
| # Relational data | |
| rel_imgs = gluon.utils.split_and_load(rel_img, ctx) | |
| rel_qsts = gluon.utils.split_and_load(rel_qst, ctx) | |
| rel_labels = gluon.utils.split_and_load(rel_label, ctx) | |
| # No-relationtional data | |
| norel_imgs = gluon.utils.split_and_load(norel_img, ctx) | |
| norel_qsts = gluon.utils.split_and_load(norel_qst, ctx) | |
| norel_labels = gluon.utils.split_and_load(norel_label, ctx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RN_Model(nn.HybridBlock): | |
| def __init__(self, **kwargs): | |
| super(RN_Model, self).__init__(**kwargs) | |
| with self.name_scope(): | |
| self.conv = ConvInputModel() | |
| self.g_fc1 = nn.Dense(256, activation='relu', flatten=False) | |
| self.g_fc2 = nn.Dense(256, activation='relu', flatten=False) | |
| self.g_fc3 = nn.Dense(256, activation='relu', flatten=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FCOutputModel(nn.HybridSequential): | |
| def __init__(self,**kwargs): | |
| super(FCOutputModel,self).__init__(**kwargs) | |
| with self.name_scope(): | |
| self.add( | |
| nn.Dense(256, activation='relu'), | |
| nn.Dropout(0.5), | |
| nn.Dense(10) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ConvInputModel(nn.HybridSequential): | |
| def __init__(self,**kwargs): | |
| super(ConvInputModel,self).__init__(**kwargs) | |
| with self.name_scope(): | |
| self.add( | |
| nn.Conv2D(channels=24, kernel_size=3, strides=2, padding=1, activation='relu'), | |
| nn.BatchNorm(), | |
| nn.Conv2D(channels=24, kernel_size=3, strides=2, padding=1, activation='relu'), | |
| nn.BatchNorm(), | |
| nn.Conv2D(channels=24, kernel_size=3, strides=2, padding=1, activation='relu'), |