示例#1
0
文件: nervanamkl.py 项目: gaokr/neon
 "assign":
 _assign_right_to_left,
 # zero_operand ops
 # unary ops
 "neg":
 lambda left: math_cpu.neg(left),
 "abs":
 lambda left: np.abs(left),
 "sgn":
 lambda left: np.sign(left),
 "sqrt":
 lambda left: math_cpu.sqrt(left),
 "sqr":
 lambda left: math_cpu.square(left),
 "exp":
 lambda left: math_cpu.exp(left),
 "log":
 lambda left: math_cpu.log(left),
 "safelog":
 lambda left: math_cpu.safelog(left),
 "exp2":
 lambda left: np.exp2(left),
 "log2":
 lambda left: np.log2(left),
 "sig":
 lambda left: 1. / (1. + np.exp(-left)),
 "sig2":
 lambda left: 1. / (1. + np.exp2(-left)),
 "tanh":
 lambda left: np.tanh(left),
 "tanh2":
示例#2
0
def _assign_right_to_left(left, right):
    math_cpu.blas_copy(left, right)


# how to overlaod numpy_call_dict?
numpy_call_dict_mkl = {
    # assign
    "assign": _assign_right_to_left,
    # zero_operand ops
    # unary ops
    "neg": lambda left: math_cpu.neg(left),
    "abs": lambda left: np.abs(left),
    "sgn": lambda left: np.sign(left),
    "sqrt": lambda left: math_cpu.sqrt(left),
    "sqr": lambda left: math_cpu.square(left),
    "exp": lambda left: math_cpu.exp(left),
    "log": lambda left: math_cpu.log(left),
    "safelog": lambda left: math_cpu.safelog(left),
    "exp2": lambda left: np.exp2(left),
    "log2": lambda left: np.log2(left),
    "sig": lambda left: 1. / (1. + np.exp(-left)),
    "sig2": lambda left: 1. / (1. + np.exp2(-left)),
    "tanh": lambda left: np.tanh(left),
    "tanh2": lambda left: (np.exp2(2. * left) - 1.) / (np.exp2(2. * left) + 1.),
    "transpose": lambda left: np.transpose(left),
    "rint": lambda left: np.rint(left),
    # binary ops
    "add": lambda left, right: math_cpu.add(left, right),
    "sub": lambda left, right: math_cpu.sub(left, right),
    "mul": lambda left, right: math_cpu.mul(left, right),
    "div": lambda left, right: math_cpu.div(left, right),