from one_shot_learning_network import *
from experiment_builder import ExperimentBuilder
import tensorflow.contrib.slim as slim
import data as dataset
import tqdm

from utils.parser_utils import get_args
from utils.storage import save_statistics, build_experiment_folder

tf.reset_default_graph()
args = get_args()
# Experiment builder
data = dataset.FolderDatasetLoader(
    num_of_gpus=1,
    batch_size=args.batch_size,
    image_height=28,
    image_width=28,
    image_channels=1,
    train_val_test_split=(1200 / 1622, 211 / 1622, 211 / 1622),
    samples_per_iter=1,
    num_workers=4,
    data_path="datasets/omniglot_data",
    name="omniglot_data",
    index_of_folder_indicating_class=-2,
    reset_stored_filepaths=False,
    num_samples_per_class=args.samples_per_class,
    num_classes_per_set=args.classes_per_set,
    label_as_int=True)

experiment = ExperimentBuilder(data)
one_shot_omniglot, losses, c_error_opt_op, init = experiment.build_experiment(
                        new_k = k.replace("ligand_arm.5", "lig_norm2")
                    elif layer_num == 9:
                        new_k = k.replace("ligand_arm.9", "lig_norm3")

                elif "protein" in k:
                    if layer_num == 0:
                        new_k = k.replace("protein_arm.0", "prot_conv1")
                    elif layer_num == 4:
                        new_k = k.replace("protein_arm.4", "prot_conv2")
                    elif layer_num == 8:
                        new_k = k.replace("protein_arm.8", "prot_conv3")
                    elif layer_num == 1:
                        new_k = k.replace("protein_arm.1", "prot_norm1")
                    elif layer_num == 5:
                        new_k = k.replace("protein_arm.5", "prot_norm2")
                    elif layer_num == 9:
                        new_k = k.replace("protein_arm.9", "prot_norm3")

            new_dict[new_k] = v
        return new_dict


if __name__ == "__main__":
    from utils.parser_utils import get_args
    args, device = get_args()
    model = DeepDTAv2Meta(args=args, device="cpu")

    print("Initial", model.state_dict()["lig_conv1.weight"].mean())
    model.load_from_path("DEEPDTAV2_SAMPLE_WEIGHT.pth")
    print("After", model.state_dict()["lig_conv1.weight"].mean())