# Path: deep_architect/contrib/misc/search_spaces/tensorflow/common.py
# D = hp.Discrete
# def siso_tensorflow_module(name, compile_fn, name_to_hyperp, scope=None):


import keras
import numpy as np
import deep_architect.modules as mo
import deep_architect.hyperparameters as hp
from deep_architect.contrib.misc.search_spaces.tensorflow.common import siso_tfm

    def compile_fn(di, dh):
        Dense = keras.layers.Dense(dh['units'])

        def fn(di):
            return {'out': Dense(di['in'])}

        return fn

    return siso_tfm('Dense', compile_fn, {'units': h_units})


def nonlinearity(h_nonlin_name):

    def compile_fn(di, dh):

        def fn(di):
            nonlin_name = dh['nonlin_name']
            if nonlin_name == 'relu':
                Out = keras.layers.Activation('relu')(di['in'])
            elif nonlin_name == 'tanh':
                Out = keras.layers.Activation('tanh')(di['in'])
            elif nonlin_name == 'elu':
                Out = keras.layers.Activation('elu')(di['in'])
            else:
                raise ValueError
            return {"out": Out}

        return fn


# Path: deep_architect/contrib/misc/search_spaces/tensorflow/common.py
# D = hp.Discrete
# def siso_tensorflow_module(name, compile_fn, name_to_hyperp, scope=None):


# Path: dev/tutorials/multiworker/search_space.py
import keras
import numpy as np
import deep_architect.modules as mo
import deep_architect.hyperparameters as hp
from deep_architect.contrib.misc.search_spaces.tensorflow.common import siso_tfm


    def compile_fn(di, dh):
        Dense = keras.layers.Dense(dh['units'])

        def fn(di):
            return {'out': Dense(di['in'])}

        return fn

    return siso_tfm('Dense', compile_fn, {'units': h_units})


def nonlinearity(h_nonlin_name):

    def compile_fn(di, dh):

        def fn(di):
            nonlin_name = dh['nonlin_name']
            if nonlin_name == 'relu':
                Out = keras.layers.Activation('relu')(di['in'])
            elif nonlin_name == 'tanh':
                Out = keras.layers.Activation('tanh')(di['in'])
            elif nonlin_name == 'elu':
                Out = keras.layers.Activation('elu')(di['in'])
            else:
                raise ValueError
            return {"out": Out}

        return fn


    return siso_tfm('Nonlinearity', compile_fn, {'nonlin_name': h_nonlin_name})