import tensorflow as tf

import tensorflow as tf
import numpy as np
try:
    import cPickle
except:
    import _pickle as cPickle


def relu(x, name, alpha):
    if alpha > 0:
        return tf.maximum(alpha * x, x, name=name)
    else:
        return tf.nn.relu(x, name=name)


def get_variable(name, shape, dtype, initializer, trainable=True, regularizer=None):
    with tf.device('/cpu:0'):
        var = tf.get_variable(name, shape=shape, dtype=dtype,
                              initializer=initializer, regularizer=regularizer, trainable=trainable,
                              collections=[tf.GraphKeys.WEIGHTS, tf.GraphKeys.GLOBAL_VARIABLES])
