Skip to content

Instantly share code, notes, and snippets.

View seujung's full-sized avatar

seujung hwan, Jung seujung

View GitHub Profile
@seujung
seujung / train_model.py
Last active August 21, 2018 07:12
relational_network_with_gluon
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)
@seujung
seujung / rn_model.py
Last active August 20, 2018 01:14
relational_network_with_gluon
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)
@seujung
seujung / fc_output_model.py
Last active August 20, 2018 01:08
relational_network_with_gluon
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)
)
@seujung
seujung / conv_input_model.py
Last active August 20, 2018 01:15
relational_network_with_gluon
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'),