np.min(image_s_trains), np.max(image_s_trains))) print("[image_t_trains] shape={}, dtype={}, min={}, max={}".format( image_t_trains.shape, image_t_trains.dtype, np.min(image_t_trains), np.max(image_t_trains))) print("[image_s_valids] shape={}, dtype={}, min={}, max={}".format( image_s_valids.shape, image_s_valids.dtype, np.min(image_s_valids), np.max(image_s_valids))) print("[image_t_valids] shape={}, dtype={}, min={}, max={}".format( image_t_valids.shape, image_t_valids.dtype, np.min(image_t_valids), np.max(image_t_valids))) #================================ # モデルの構造を定義する。 #================================ with mirrored_strategy.scope(): model_G = TempleteNetworks(out_dim=3) model_G( tf.zeros([args.batch_size, args.image_height, args.image_width, 3], dtype=tf.float32)) #================================ # loss 設定 #================================ with mirrored_strategy.scope(): loss_mse = tf.keras.losses.MeanSquaredError() #================================ # optimizer 設定 #================================ with mirrored_strategy.scope(): optimizer_G = tf.keras.optimizers.Adam(learning_rate=args.lr,
args.dataset_dir, datamode="test", image_height=args.image_height, image_width=args.image_width, data_augument=False, debug=args.debug) dloader_test = torch.utils.data.DataLoader(ds_test, batch_size=args.batch_size_test, shuffle=False, num_workers=args.n_workers, pin_memory=True) #================================ # モデルの構造を定義する。 #================================ model_G = TempleteNetworks().to(device) if (args.debug): print("model_G\n", model_G) # モデルを読み込む if not args.load_checkpoints_path == '' and os.path.exists( args.load_checkpoints_path): load_checkpoint(model_G, device, args.load_checkpoints_path) #================================ # モデルの推論 #================================ print("Starting Testing Loop...") n_print = 1 model_G.eval() for step, inputs in enumerate(tqdm(dloader_test, desc="Samplings")):
data_augument=False) #================================ # 変数とプレースホルダを設定 #================================ image_s_holder = tf.placeholder( tf.float32, [None, args.image_height, args.image_width, 3], name="image_s_holder") image_t_holder = tf.placeholder( tf.float32, [None, args.image_height, args.image_width, 3], name="image_t_holder") #================================ # モデルの構造を定義する。 #================================ model_G = TempleteNetworks(out_dim=3) output_op = model_G(image_s_holder) #================================ # loss 関数の設定 #================================ with tf.name_scope('loss'): loss_op = tf.reduce_mean(tf.abs(image_t_holder - output_op)) #================================ # optimizer の設定 #================================ with tf.name_scope('optimizer'): optimizer_op = tf.train.AdamOptimizer(learning_rate=args.lr, beta1=args.beta1, beta2=args.beta2)
image_height=args.image_height, image_width=args.image_width, n_channels=3, batch_size=args.batch_size, use_tfrecord=args.use_tfrecord, seed=args.seed) if (args.debug): print("n_trains : ", n_trains) print("n_valids : ", n_valids) print("ds_train : ", ds_train) print("ds_valid : ", ds_valid) #================================ # モデルの構造を定義する。 #================================ model_G = TempleteNetworks(out_dim=3) if (args.debug): model_G( tf.zeros([args.batch_size, args.image_height, args.image_width, 3], dtype=tf.float32) ) # 動的作成されるネットワークなので、一度ネットワークに入力データを供給しないと summary() を出力できない model_G.summary() #================================ # モデルの読み込み #================================ if (args.load_checkpoints_dir): ckpt_state = tf.train.get_checkpoint_state(args.load_checkpoints_dir) model_G.load_weights(ckpt_state.model_checkpoint_path) print("load checkpoints in `{}`.".format( ckpt_state.model_checkpoint_path))
dloader_train = torch.utils.data.DataLoader(Subset(ds_train, train_index), batch_size=args.batch_size, shuffle=True, num_workers=args.n_workers, pin_memory=True) dloader_valid = torch.utils.data.DataLoader( Subset(ds_train, valid_index), batch_size=args.batch_size_valid, shuffle=False, num_workers=args.n_workers, pin_memory=True) #================================ # モデルの構造を定義する。 #================================ model_G = TempleteNetworks().to(device) if (args.debug): print("model_G\n", model_G) # モデルを読み込む if not args.load_checkpoints_path == '' and os.path.exists( args.load_checkpoints_path): load_checkpoint(model_G, device, args.load_checkpoints_path) #================================ # optimizer_G の設定 #================================ optimizer_G = optim.Adam(params=model_G.parameters(), lr=args.lr, betas=(args.beta1, args.beta2))