本文整理汇总了Python中model.net.Net方法的典型用法代码示例。如果您正苦于以下问题:Python net.Net方法的具体用法?Python net.Net怎么用?Python net.Net使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.net
的用法示例。
在下文中一共展示了net.Net方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from model import net [as 别名]
# 或者: from model.net import Net [as 别名]
def main():
dataloader = DataLoader(config, args.data_dir, args.img_dir, args.year, args.test_set, batch_size)
model = Net(config=config, no_words=dataloader.tokenizer.no_words, no_answers=dataloader.tokenizer.no_answers,
resnet_model=resnet_model, lstm_size=lstm_size, emb_size=emb_size, use_pretrained=False).cuda()
optimizer = optim.Adam(model.parameters(), lr=lr)
train(dataloader, model, optimizer)
示例2: build_test
# 需要导入模块: from model import net [as 别名]
# 或者: from model.net import Net [as 别名]
def build_test(self, build_type='both'):
self.loader = DataLoader(trainable=False, **self.config)
self.num_scales = self.loader.num_scales
self.num_source = self.loader.num_source
with tf.name_scope('data_loading'):
self.tgt_image_uint8 = tf.placeholder(tf.uint8, [self.loader.batch_size,
self.loader.img_height, self.loader.img_width, 3])
self.tgt_image = tf.image.convert_image_dtype(self.tgt_image_uint8, dtype=tf.float32)
tgt_image_net = self.preprocess_image(self.tgt_image)
if build_type != 'depth':
self.src_image_stack_uint8 = tf.placeholder(tf.uint8, [self.loader.batch_size,
self.loader.img_height, self.loader.img_width, 3 * self.num_source])
self.src_image_stack = tf.image.convert_image_dtype(self.src_image_stack_uint8, dtype=tf.float32)
src_image_stack_net = self.preprocess_image(self.src_image_stack)
with tf.variable_scope('monodepth2_model', reuse=tf.AUTO_REUSE) as scope:
net_builder = Net(False, **self.config)
res18_tc, skips_tc = net_builder.build_resnet18(tgt_image_net)
pred_disp = net_builder.build_disp_net(res18_tc, skips_tc)
pred_disp_rawscale = [tf.image.resize_bilinear(pred_disp[i], [self.loader.img_height, self.loader.img_width]) for i in
range(self.num_scales)]
pred_depth_rawscale = disp_to_depth(pred_disp_rawscale, self.min_depth, self.max_depth)
self.pred_depth = pred_depth_rawscale[0]
self.pred_disp = pred_disp_rawscale[0]
if build_type != 'depth':
num_source = np.int(src_image_stack_net.get_shape().as_list()[-1] // 3)
assert num_source == 2
if self.pose_type == 'seperate':
res18_ctp, _ = net_builder.build_resnet18(
tf.concat([src_image_stack_net[:, :, :, :3], tgt_image_net], axis=3),
prefix='pose_'
)
res18_ctn, _ = net_builder.build_resnet18(
tf.concat([tgt_image_net, src_image_stack_net[:, :, :, 3:]], axis=3),
prefix='pose_'
)
elif self.pose_type == 'shared':
res18_tp, _ = net_builder.build_resnet18(src_image_stack_net[:, :, :, :3])
res18_tn, _ = net_builder.build_resnet18(src_image_stack_net[:, :, :, 3:])
res18_ctp = tf.concat([res18_tc, res18_tp], axis=3)
res18_ctn = tf.concat([res18_tc, res18_tn], axis=3)
else:
raise NotImplementedError
pred_pose_ctp = net_builder.build_pose_net2(res18_ctp)
pred_pose_ctn = net_builder.build_pose_net2(res18_ctn)
pred_poses = tf.concat([pred_pose_ctp, pred_pose_ctn], axis=1)
self.pred_poses = pred_poses