In [1]:
import numpy as np
from keras import activations
from keras import backend as K
import json
from collections import OrderedDict
In [2]:
def format_decimal(arr):
return [round(x * 1e6) / 1e6 for x in arr]
In [3]:
DATA = OrderedDict()
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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}}
[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 [34]:
print(json.dumps(DATA))