# Path: deep_architect/contrib/misc/datasets/loaders.py
# def load_mnist(flatten=False, one_hot=True, validation_frac=0.1):
#     from keras.datasets import mnist
#     (X_train, y_train), (X_test, y_test) = mnist.load_data()
#     X_train = X_train / 255.0
#     X_test = X_test / 255.0
#     if flatten:
#         X_train = X_train.reshape((X_train.shape[0], -1))
#         X_test = X_test.reshape((X_test.shape[0], -1))
#     if one_hot:
#         y_train = au.idx_to_onehot(y_train, 10)
#         y_test = au.idx_to_onehot(y_test, 10)
#     num_train = int((1.0 - validation_frac) * X_train.shape[0])
#     X_train, X_val = X_train[:num_train], X_train[num_train:]
#     y_train, y_val = y_train[:num_train], y_train[num_train:]
#     return (X_train, y_train, X_val, y_val, X_test, y_test)


import dynet as dy
import numpy as np
import deep_architect.modules as mo
import deep_architect.hyperparameters as hp
import deep_architect.searchers.random as se
import deep_architect.core as co
import random
from deep_architect.helpers.dynet_support import DyParameterCollection, siso_dynet_module
from deep_architect.contrib.misc.datasets.loaders import load_mnist
    ])


# Main/Searcher
# Getting and reading mnist data adapted from here:
# https://github.com/clab/dynet/blob/master/examples/mnist/mnist-autobatch.py


def get_search_space(num_classes):

    def fn():
        co.Scope.reset_default_scope()
        inputs, outputs = dnn_net(num_classes)
        return inputs, outputs, {}

    return fn


def main():

    num_classes = 10
    num_samples = 3  # number of architecture to sample
    best_val_acc, best_architecture = 0., -1

    # donwload and normalize data, using test as val for simplicity
    X_train, y_train, X_val, y_val, _, _ = load_mnist('data/mnist',
                                                      normalize_range=True)

    # defining evaluator
    evaluator = SimpleClassifierEvaluator((X_train, y_train), (X_val, y_val),

# Path: deep_architect/contrib/misc/datasets/loaders.py
# def load_mnist(flatten=False, one_hot=True, validation_frac=0.1):
#     from keras.datasets import mnist
#     (X_train, y_train), (X_test, y_test) = mnist.load_data()
#     X_train = X_train / 255.0
#     X_test = X_test / 255.0
#     if flatten:
#         X_train = X_train.reshape((X_train.shape[0], -1))
#         X_test = X_test.reshape((X_test.shape[0], -1))
#     if one_hot:
#         y_train = au.idx_to_onehot(y_train, 10)
#         y_test = au.idx_to_onehot(y_test, 10)
#     num_train = int((1.0 - validation_frac) * X_train.shape[0])
#     X_train, X_val = X_train[:num_train], X_train[num_train:]
#     y_train, y_val = y_train[:num_train], y_train[num_train:]
#     return (X_train, y_train, X_val, y_val, X_test, y_test)


# Path: dev/tutorials/mnist/dynet/mnist_dynet.py
import dynet as dy
import numpy as np
import deep_architect.modules as mo
import deep_architect.hyperparameters as hp
import deep_architect.searchers.random as se
import deep_architect.core as co
import random
from deep_architect.helpers.dynet_support import DyParameterCollection, siso_dynet_module
from deep_architect.contrib.misc.datasets.loaders import load_mnist

    ])


# Main/Searcher
# Getting and reading mnist data adapted from here:
# https://github.com/clab/dynet/blob/master/examples/mnist/mnist-autobatch.py


def get_search_space(num_classes):

    def fn():
        co.Scope.reset_default_scope()
        inputs, outputs = dnn_net(num_classes)
        return inputs, outputs, {}

    return fn


def main():

    num_classes = 10
    num_samples = 3  # number of architecture to sample
    best_val_acc, best_architecture = 0., -1

    # donwload and normalize data, using test as val for simplicity
    X_train, y_train, X_val, y_val, _, _ = load_mnist('data/mnist',
                                                      normalize_range=True)

    # defining evaluator
    evaluator = SimpleClassifierEvaluator((X_train, y_train), (X_val, y_val),

                                          num_classes,