'b_norm_decay'] = 1.  # for avoiding the update of batch normalization moving_mean and moving_variance parameters
    conf.decoder_args[
        'b_norm_decay'] = 1.  # for avoiding the update of batch normalization moving_mean and moving_variance parameters
    conf.decoder_args[
        'b_norm_decay_finish'] = 1.  # for avoiding the update of batch normalization moving_mean and moving_variance parameters

conf.encoder_args['return_layer_before_symmetry'] = True

# sampler configuration
conf.experiment_name = 'sampler'
conf.n_samp = [flags.n_sample_points, 3]  # Dimensionality of sampled points.
conf.sampler = sampler_with_convs_and_symmetry_and_fc
conf.similarity_reg_weight = flags.similarity_reg_weight
conf.learning_rate = flags.learning_rate

train_dir = create_dir(osp.join(top_out_dir, flags.train_folder))
conf.train_dir = train_dir

conf.save(osp.join(train_dir, 'configuration'))

# Build Sampler and AE Model
reset_tf_graph()
ae = SNetPointNetAutoEncoder(conf.experiment_name, conf)

# Train the sampler (save output to train_stats.txt)
buf_size = 1  # Make 'training_stats' file to flush each output line regarding training.
fout = open(osp.join(conf.train_dir, 'train_stats.txt'), 'a', buf_size)
train_stats = ae.train(pc_data_train,
                       conf,
                       log_file=fout,
                       held_out_data=pc_data_val)
# Load configuration
train_dir = osp.join(top_out_dir, flags.train_folder)
restore_epoch = 500
conf = Conf.load(osp.join(train_dir, 'configuration'))

conf.encoder_args['return_layer_before_symmetry'] = True

# Reload a saved model
reset_tf_graph()
ae = SNetPointNetAutoEncoder(conf.experiment_name, conf)
ae.restore_model(train_dir, epoch=restore_epoch, verbose=True)

n_sample_points = conf.n_samp[0]

# create evaluation dir
eval_dir = create_dir(osp.join(train_dir, "eval"))

# sample point clouds
_, sampled_pc, sample_idx, _ = ae.get_samples(
    pc_data_test.point_clouds)  # S-NET sampled points

# save sampled point cloud and sample index
file_name = "_".join(
    ["sampled_pc", "test_set", flags.object_class,
     "%04d" % n_sample_points]) + ".npy"
file_path = osp.join(eval_dir, file_name)
np.save(file_path, sampled_pc)

file_name = "_".join(
    ["sample_idx", "test_set", flags.object_class,
     "%04d" % n_sample_points]) + ".npy"