In [2]:
import numpy as np
import json
from keras.models import Model
from keras.layers import Input, Activation
from keras import backend as K


Using TensorFlow backend.

In [3]:
def format_decimal(arr, places=8):
    return [round(x * 10**places) / 10**places for x in arr]

pipeline 19


In [19]:
data_in_shape = (3, 3)

input_layer = Input(shape=data_in_shape)
output_layer = Activation('relu', input_shape=data_in_shape)(input_layer)
model = Model(input=input_layer, output=output_layer)

np.random.seed(1000)
data_in = 2 * np.random.random(data_in_shape) - 1

weights = []

result = model.predict(np.array([data_in]))

print({
    'input': {'data': format_decimal(data_in.ravel().tolist()), 'shape': list(data_in_shape)},
    'weights': [{'data': format_decimal(weights[i].ravel().tolist()), 'shape': list(weights[i].shape)} for i in range(len(weights))],
    'expected': {'data': format_decimal(result[0].ravel().tolist()), 'shape': list(result[0].shape)}
})


{'weights': [], 'input': {'data': [0.30717917, -0.76998611, 0.90056573, -0.0356172, 0.74494907, -0.57533464, -0.91858075, -0.20561108, -0.53373561], 'shape': [3, 3]}, 'expected': {'data': [0.30717918, 0.0, 0.90056574, 0.0, 0.74494904, 0.0, 0.0, 0.0, 0.0], 'shape': [3, 3]}}

In [ ]: