In [1]:
import numpy as np
from keras import activations
from keras import backend as K
import json
from collections import OrderedDict


Using TensorFlow backend.

In [2]:
def format_decimal(arr):
    return [round(x * 1e6) / 1e6 for x in arr]

In [3]:
DATA = OrderedDict()

softmax

[activations.softmax.0] 1D


In [4]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2]
data_in_shape = (6,)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.softmax(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.softmax.0'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                 'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (6,)
out: [0.067194, 0.082071, 0.110784, 0.0608, 0.182652, 0.4965]

[activations.softmax.1] 2D


In [5]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 6)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.softmax(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.softmax.1'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                 'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
in shape: (2, 6)
out shape: (2, 6)
out: [0.067194, 0.082071, 0.110784, 0.0608, 0.182652, 0.4965, 0.107768, 0.149902, 0.11105, 0.247147, 0.082268, 0.301865]

[activations.softmax.2] 1D


In [6]:
data_in = [0, 0.2, 0.5, -0.1, 1, 90]
data_in_shape = (6,)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.softmax(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.softmax.2'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                 'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 90]
in shape: (6,)
out shape: (6,)
out: [0.0, 0.0, 0.0, 0.0, 0.0, 1.0]

elu

[activations.elu.0] 1D


In [7]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2]
data_in_shape = (6,)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.elu(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.elu.0'] = {'input': {'data': data_in, 'shape': data_in_shape},
                             'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (6,)
out: [0.0, 0.2, 0.5, -0.095163, 1.0, 2.0]

[activations.elu.1] 2D


In [8]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 6)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.elu(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.elu.1'] = {'input': {'data': data_in, 'shape': data_in_shape},
                             'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
in shape: (2, 6)
out shape: (2, 6)
out: [0.0, 0.2, 0.5, -0.095163, 1.0, 2.0, -0.029555, 0.3, 0.0, 0.8, -0.259182, 1.0]

[activations.elu.2] 3D


In [9]:
data_in = [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 2, 3)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.elu(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.elu.2'] = {'input': {'data': data_in, 'shape': data_in_shape},
                             'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
in shape: (2, 2, 3)
out shape: (2, 2, 3)
out: [0.0, 0.2, -0.393469, -0.095163, 1.0, 2.0, -0.029555, 2.3, 0.0, 0.8, -0.259182, 1.0]

[activations.elu.3] 3D, alpha=0.5


In [10]:
data_in = [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 2, 3)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.elu(K.variable(np.array([arr_in])), alpha=0.5)

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.elu.3'] = {'input': {'data': data_in, 'shape': data_in_shape},
                             'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
in shape: (2, 2, 3)
out shape: (2, 2, 3)
out: [0.0, 0.2, -0.196735, -0.047581, 1.0, 2.0, -0.014777, 2.3, 0.0, 0.8, -0.129591, 1.0]

softplus

[activations.softplus.0] 1D


In [11]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2]
data_in_shape = (6,)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.softplus(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.softplus.0'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                  'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (6,)
out: [0.693147, 0.798139, 0.974077, 0.644397, 1.313262, 2.126928]

[activations.softplus.1] 2D


In [12]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 6)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.softplus(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.softplus.1'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                  'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
in shape: (2, 6)
out shape: (2, 6)
out: [0.693147, 0.798139, 0.974077, 0.644397, 1.313262, 2.126928, 0.67826, 0.854355, 0.693147, 1.171101, 0.554355, 1.313262]

[activations.softplus.2] 3D


In [13]:
data_in = [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 2, 3)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.softplus(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.softplus.2'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                  'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
in shape: (2, 2, 3)
out shape: (2, 2, 3)
out: [0.693147, 0.798139, 0.474077, 0.644397, 1.313262, 2.126928, 0.67826, 2.395545, 0.693147, 1.171101, 0.554355, 1.313262]

softsign

[activations.softsign.0] 1D


In [14]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2]
data_in_shape = (6,)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.softsign(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.softsign.0'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                  'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (6,)
out: [0.0, 0.166667, 0.333333, -0.090909, 0.5, 0.666667]

[activations.softsign.1] 2D


In [15]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 6)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.softsign(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.softsign.1'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                  'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
in shape: (2, 6)
out shape: (2, 6)
out: [0.0, 0.166667, 0.333333, -0.090909, 0.5, 0.666667, -0.029126, 0.230769, 0.0, 0.444444, -0.230769, 0.5]

[activations.softsign.2] 3D


In [16]:
data_in = [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 2, 3)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.softsign(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.softsign.2'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                  'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
in shape: (2, 2, 3)
out shape: (2, 2, 3)
out: [0.0, 0.166667, -0.333333, -0.090909, 0.5, 0.666667, -0.029126, 0.69697, 0.0, 0.444444, -0.230769, 0.5]

ReLU

[activations.relu.0] 1D


In [17]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2]
data_in_shape = (6,)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.relu(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.relu.0'] = {'input': {'data': data_in, 'shape': data_in_shape},
                              'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (6,)
out: [0.0, 0.2, 0.5, 0.0, 1.0, 2.0]

[activations.relu.1] 2D


In [18]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 6)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.relu(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.relu.1'] = {'input': {'data': data_in, 'shape': data_in_shape},
                              'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
in shape: (2, 6)
out shape: (2, 6)
out: [0.0, 0.2, 0.5, 0.0, 1.0, 2.0, 0.0, 0.3, 0.0, 0.8, 0.0, 1.0]

[activations.relu.2] 3D


In [19]:
data_in = [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 2, 3)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.relu(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.relu.2'] = {'input': {'data': data_in, 'shape': data_in_shape},
                              'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
in shape: (2, 2, 3)
out shape: (2, 2, 3)
out: [0.0, 0.2, 0.0, 0.0, 1.0, 2.0, 0.0, 2.3, 0.0, 0.8, 0.0, 1.0]

[activations.relu.3] 3D, max_value=0.5


In [20]:
data_in = [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 2, 3)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.relu(K.variable(np.array([arr_in])), max_value=0.5)

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.relu.3'] = {'input': {'data': data_in, 'shape': data_in_shape},
                              'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
in shape: (2, 2, 3)
out shape: (2, 2, 3)
out: [0.0, 0.2, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5]

[activations.relu.4] 3D, alpha=0.3


In [21]:
data_in = [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 2, 3)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.relu(K.variable(np.array([arr_in])), alpha=0.3)

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.relu.4'] = {'input': {'data': data_in, 'shape': data_in_shape},
                              'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
in shape: (2, 2, 3)
out shape: (2, 2, 3)
out: [0.0, 0.2, -0.15, -0.03, 1.0, 2.0, -0.009, 2.3, 0.0, 0.8, -0.09, 1.0]

tanh

[activations.tanh.0] 1D


In [22]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2]
data_in_shape = (6,)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.tanh(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.tanh.0'] = {'input': {'data': data_in, 'shape': data_in_shape},
                              'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (6,)
out: [0.0, 0.197375, 0.462117, -0.099668, 0.761594, 0.964028]

[activations.tanh.1] 2D


In [23]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 6)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.tanh(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.tanh.1'] = {'input': {'data': data_in, 'shape': data_in_shape},
                              'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
in shape: (2, 6)
out shape: (2, 6)
out: [0.0, 0.197375, 0.462117, -0.099668, 0.761594, 0.964028, -0.029991, 0.291313, 0.0, 0.664037, -0.291313, 0.761594]

[activations.tanh.2] 3D


In [24]:
data_in = [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 2, 3)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.tanh(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.tanh.2'] = {'input': {'data': data_in, 'shape': data_in_shape},
                              'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
in shape: (2, 2, 3)
out shape: (2, 2, 3)
out: [0.0, 0.197375, -0.462117, -0.099668, 0.761594, 0.964028, -0.029991, 0.980096, 0.0, 0.664037, -0.291313, 0.761594]

sigmoid

[activations.sigmoid.0] 1D


In [25]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2]
data_in_shape = (6,)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.sigmoid(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.sigmoid.0'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                 'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (6,)
out: [0.5, 0.549834, 0.622459, 0.475021, 0.731059, 0.880797]

[activations.sigmoid.1] 2D


In [26]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 6)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.sigmoid(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.sigmoid.1'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                 'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
in shape: (2, 6)
out shape: (2, 6)
out: [0.5, 0.549834, 0.622459, 0.475021, 0.731059, 0.880797, 0.492501, 0.574443, 0.5, 0.689974, 0.425557, 0.731059]

[activations.sigmoid.2] 3D


In [27]:
data_in = [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 2, 3)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.sigmoid(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.sigmoid.2'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                 'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
in shape: (2, 2, 3)
out shape: (2, 2, 3)
out: [0.5, 0.549834, 0.377541, 0.475021, 0.731059, 0.880797, 0.492501, 0.908877, 0.5, 0.689974, 0.425557, 0.731059]

hard_sigmoid

[activations.hard_sigmoid.0] 1D


In [28]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2]
data_in_shape = (6,)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.hard_sigmoid(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.hard_sigmoid.0'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                      'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (6,)
out: [0.5, 0.54, 0.6, 0.48, 0.7, 0.9]

[activations.hard_sigmoid.1] 2D


In [29]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 6)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.hard_sigmoid(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.hard_sigmoid.1'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                      'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
in shape: (2, 6)
out shape: (2, 6)
out: [0.5, 0.54, 0.6, 0.48, 0.7, 0.9, 0.494, 0.56, 0.5, 0.66, 0.44, 0.7]

[activations.hard_sigmoid.2] 3D


In [30]:
data_in = [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 2, 3)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.hard_sigmoid(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.hard_sigmoid.2'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                      'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
in shape: (2, 2, 3)
out shape: (2, 2, 3)
out: [0.5, 0.54, 0.4, 0.48, 0.7, 0.9, 0.494, 0.96, 0.5, 0.66, 0.44, 0.7]

linear

[activations.linear.0] 1D


In [31]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2]
data_in_shape = (6,)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.linear(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.linear.0'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (6,)
out: [0.0, 0.2, 0.5, -0.1, 1.0, 2.0]

[activations.linear.1] 2D


In [32]:
data_in = [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 6)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.linear(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.linear.1'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1]
in shape: (2, 6)
out shape: (2, 6)
out: [0.0, 0.2, 0.5, -0.1, 1.0, 2.0, -0.03, 0.3, 0.0, 0.8, -0.3, 1.0]

[activations.linear.2] 3D


In [33]:
data_in = [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
data_in_shape = (2, 2, 3)
print('in:', data_in)
print('in shape:', data_in_shape)
arr_in = np.array(data_in, dtype='float32').reshape(data_in_shape)

result = activations.linear(K.variable(np.array([arr_in])))

arr_out = K.eval(result)[0]
data_out_shape = arr_out.shape
print('out shape:', data_out_shape)
data_out = format_decimal(arr_out.ravel().tolist())
print('out:', data_out)

DATA['activations.linear.2'] = {'input': {'data': data_in, 'shape': data_in_shape},
                                'expected': {'data': data_out, 'shape': data_out_shape}}


in: [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1]
in shape: (2, 2, 3)
out shape: (2, 2, 3)
out: [0.0, 0.2, -0.5, -0.1, 1.0, 2.0, -0.03, 2.3, 0.0, 0.8, -0.3, 1.0]

export for Keras.js tests


In [34]:
print(json.dumps(DATA))


{"activations.softmax.0": {"expected": {"data": [0.067194, 0.082071, 0.110784, 0.0608, 0.182652, 0.4965], "shape": [6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}}, "activations.softmax.1": {"expected": {"data": [0.067194, 0.082071, 0.110784, 0.0608, 0.182652, 0.4965, 0.107768, 0.149902, 0.11105, 0.247147, 0.082268, 0.301865], "shape": [2, 6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1], "shape": [2, 6]}}, "activations.softmax.2": {"expected": {"data": [0.0, 0.0, 0.0, 0.0, 0.0, 1.0], "shape": [6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 90], "shape": [6]}}, "activations.elu.0": {"expected": {"data": [0.0, 0.2, 0.5, -0.095163, 1.0, 2.0], "shape": [6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}}, "activations.elu.1": {"expected": {"data": [0.0, 0.2, 0.5, -0.095163, 1.0, 2.0, -0.029555, 0.3, 0.0, 0.8, -0.259182, 1.0], "shape": [2, 6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1], "shape": [2, 6]}}, "activations.elu.2": {"expected": {"data": [0.0, 0.2, -0.393469, -0.095163, 1.0, 2.0, -0.029555, 2.3, 0.0, 0.8, -0.259182, 1.0], "shape": [2, 2, 3]}, "input": {"data": [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1], "shape": [2, 2, 3]}}, "activations.elu.3": {"expected": {"data": [0.0, 0.2, -0.196735, -0.047581, 1.0, 2.0, -0.014777, 2.3, 0.0, 0.8, -0.129591, 1.0], "shape": [2, 2, 3]}, "input": {"data": [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1], "shape": [2, 2, 3]}}, "activations.softplus.0": {"expected": {"data": [0.693147, 0.798139, 0.974077, 0.644397, 1.313262, 2.126928], "shape": [6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}}, "activations.softplus.1": {"expected": {"data": [0.693147, 0.798139, 0.974077, 0.644397, 1.313262, 2.126928, 0.67826, 0.854355, 0.693147, 1.171101, 0.554355, 1.313262], "shape": [2, 6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1], "shape": [2, 6]}}, "activations.softplus.2": {"expected": {"data": [0.693147, 0.798139, 0.474077, 0.644397, 1.313262, 2.126928, 0.67826, 2.395545, 0.693147, 1.171101, 0.554355, 1.313262], "shape": [2, 2, 3]}, "input": {"data": [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1], "shape": [2, 2, 3]}}, "activations.softsign.0": {"expected": {"data": [0.0, 0.166667, 0.333333, -0.090909, 0.5, 0.666667], "shape": [6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}}, "activations.softsign.1": {"expected": {"data": [0.0, 0.166667, 0.333333, -0.090909, 0.5, 0.666667, -0.029126, 0.230769, 0.0, 0.444444, -0.230769, 0.5], "shape": [2, 6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1], "shape": [2, 6]}}, "activations.softsign.2": {"expected": {"data": [0.0, 0.166667, -0.333333, -0.090909, 0.5, 0.666667, -0.029126, 0.69697, 0.0, 0.444444, -0.230769, 0.5], "shape": [2, 2, 3]}, "input": {"data": [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1], "shape": [2, 2, 3]}}, "activations.relu.0": {"expected": {"data": [0.0, 0.2, 0.5, 0.0, 1.0, 2.0], "shape": [6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}}, "activations.relu.1": {"expected": {"data": [0.0, 0.2, 0.5, 0.0, 1.0, 2.0, 0.0, 0.3, 0.0, 0.8, 0.0, 1.0], "shape": [2, 6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1], "shape": [2, 6]}}, "activations.relu.2": {"expected": {"data": [0.0, 0.2, 0.0, 0.0, 1.0, 2.0, 0.0, 2.3, 0.0, 0.8, 0.0, 1.0], "shape": [2, 2, 3]}, "input": {"data": [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1], "shape": [2, 2, 3]}}, "activations.relu.3": {"expected": {"data": [0.0, 0.2, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5], "shape": [2, 2, 3]}, "input": {"data": [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1], "shape": [2, 2, 3]}}, "activations.relu.4": {"expected": {"data": [0.0, 0.2, -0.15, -0.03, 1.0, 2.0, -0.009, 2.3, 0.0, 0.8, -0.09, 1.0], "shape": [2, 2, 3]}, "input": {"data": [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1], "shape": [2, 2, 3]}}, "activations.tanh.0": {"expected": {"data": [0.0, 0.197375, 0.462117, -0.099668, 0.761594, 0.964028], "shape": [6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}}, "activations.tanh.1": {"expected": {"data": [0.0, 0.197375, 0.462117, -0.099668, 0.761594, 0.964028, -0.029991, 0.291313, 0.0, 0.664037, -0.291313, 0.761594], "shape": [2, 6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1], "shape": [2, 6]}}, "activations.tanh.2": {"expected": {"data": [0.0, 0.197375, -0.462117, -0.099668, 0.761594, 0.964028, -0.029991, 0.980096, 0.0, 0.664037, -0.291313, 0.761594], "shape": [2, 2, 3]}, "input": {"data": [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1], "shape": [2, 2, 3]}}, "activations.sigmoid.0": {"expected": {"data": [0.5, 0.549834, 0.622459, 0.475021, 0.731059, 0.880797], "shape": [6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}}, "activations.sigmoid.1": {"expected": {"data": [0.5, 0.549834, 0.622459, 0.475021, 0.731059, 0.880797, 0.492501, 0.574443, 0.5, 0.689974, 0.425557, 0.731059], "shape": [2, 6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1], "shape": [2, 6]}}, "activations.sigmoid.2": {"expected": {"data": [0.5, 0.549834, 0.377541, 0.475021, 0.731059, 0.880797, 0.492501, 0.908877, 0.5, 0.689974, 0.425557, 0.731059], "shape": [2, 2, 3]}, "input": {"data": [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1], "shape": [2, 2, 3]}}, "activations.hard_sigmoid.0": {"expected": {"data": [0.5, 0.54, 0.6, 0.48, 0.7, 0.9], "shape": [6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}}, "activations.hard_sigmoid.1": {"expected": {"data": [0.5, 0.54, 0.6, 0.48, 0.7, 0.9, 0.494, 0.56, 0.5, 0.66, 0.44, 0.7], "shape": [2, 6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1], "shape": [2, 6]}}, "activations.hard_sigmoid.2": {"expected": {"data": [0.5, 0.54, 0.4, 0.48, 0.7, 0.9, 0.494, 0.96, 0.5, 0.66, 0.44, 0.7], "shape": [2, 2, 3]}, "input": {"data": [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1], "shape": [2, 2, 3]}}, "activations.linear.0": {"expected": {"data": [0.0, 0.2, 0.5, -0.1, 1.0, 2.0], "shape": [6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}}, "activations.linear.1": {"expected": {"data": [0.0, 0.2, 0.5, -0.1, 1.0, 2.0, -0.03, 0.3, 0.0, 0.8, -0.3, 1.0], "shape": [2, 6]}, "input": {"data": [0, 0.2, 0.5, -0.1, 1, 2, -0.03, 0.3, 0, 0.8, -0.3, 1], "shape": [2, 6]}}, "activations.linear.2": {"expected": {"data": [0.0, 0.2, -0.5, -0.1, 1.0, 2.0, -0.03, 2.3, 0.0, 0.8, -0.3, 1.0], "shape": [2, 2, 3]}, "input": {"data": [0, 0.2, -0.5, -0.1, 1, 2, -0.03, 2.3, 0, 0.8, -0.3, 1], "shape": [2, 2, 3]}}}