<jupyter_start><jupyter_text>Highway **[legacy.Highway.0]**<jupyter_code>data_in_shape = (6,)
layer_0 = Input(shape=data_in_shape)
layer_1 = Highway(activation='linear', bias=True)(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)

# set weights to random (use seed for reproducibility)
weights = []
for i, w in enumerate(model.get_weights()):
    np.random.seed(20+i)
    weights.append(2 * np.random.random(w.shape) - 1)
model.set_weights(weights)
print('W shape:', weights[0].shape)
print('W:', format_decimal(weights[0].ravel().tolist()))
print('W_carry shape:', weights[1].shape)
print('W_carry:', format_decimal(weights[1].ravel().tolist()))
print('b shape:', weights[2].shape)
print('b:', format_decimal(weights[2].ravel().tolist()))
print('b_carry shape:', weights[3].shape)
print('b_carry:', format_decimal(weights[3].ravel().tolist()))

data_in = 2 * np.random.random(data_in_shape) - 1
result = model.predict(np.array([data_in]))
data_out_shape = result[0].shape
data_in_formatted = format_decimal(data_in.ravel().tolist())
data_out_formatted = format_decimal(result[0].ravel().tolist())
print('')
print('in shape:', data_in_shape)
print('in:', data_in_formatted)
print('out shape:', data_out_shape)
print('out:', data_out_formatted)

DATA['legacy.Highway.0'] = {
    'input': {'data': data_in_formatted, 'shape': data_in_shape},
    'weights': [{'data': format_decimal(w.ravel().tolist()), 'shape': w.shape} for w in weights],
    'expected': {'data': data_out_formatted, 'shape': data_out_shape}
}<jupyter_output>/home/leon/miniconda3/lib/python3.5/site-packages/keras/legacy/layers.py:654: UserWarning: The `Highway` layer is deprecated and will be removed after 06/2017.
  warnings.warn('The `Highway` layer is deprecated '<jupyter_text>**[legacy.Highway.1]**<jupyter_code>data_in_shape = (5,)
layer_0 = Input(shape=data_in_shape)
layer_1 = Highway(activation='tanh', bias=True)(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)

# set weights to random (use seed for reproducibility)
weights = []
for i, w in enumerate(model.get_weights()):
    np.random.seed(30+i)
    weights.append(2 * np.random.random(w.shape) - 1)
model.set_weights(weights)
print('W shape:', weights[0].shape)
print('W:', format_decimal(weights[0].ravel().tolist()))
print('W_carry shape:', weights[1].shape)
print('W_carry:', format_decimal(weights[1].ravel().tolist()))
print('b shape:', weights[2].shape)
print('b:', format_decimal(weights[2].ravel().tolist()))
print('b_carry shape:', weights[3].shape)
print('b_carry:', format_decimal(weights[3].ravel().tolist()))

data_in = 2 * np.random.random(data_in_shape) - 1
result = model.predict(np.array([data_in]))
data_out_shape = result[0].shape
data_in_formatted = format_decimal(data_in.ravel().tolist())
data_out_formatted = format_decimal(result[0].ravel().tolist())
print('')
print('in shape:', data_in_shape)
print('in:', data_in_formatted)
print('out shape:', data_out_shape)
print('out:', data_out_formatted)

DATA['legacy.Highway.1'] = {
    'input': {'data': data_in_formatted, 'shape': data_in_shape},
    'weights': [{'data': format_decimal(w.ravel().tolist()), 'shape': w.shape} for w in weights],
    'expected': {'data': data_out_formatted, 'shape': data_out_shape}
}
data_in_shape = (4,)
layer_0 = Input(shape=data_in_shape)
layer_1 = Highway(activation='hard_sigmoid', bias=False)(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)

# set weights to random (use seed for reproducibility)
weights = []
for i, w in enumerate(model.get_weights()):
    np.random.seed(40+i)
    weights.append(2 * np.random.random(w.shape) - 1)
model.set_weights(weights)
print('W shape:', weights[0].shape)
print('W:', format_decimal(weights[0].ravel().tolist()))
print('W_carry shape:', weights[1].shape)
print('W_carry:', format_decimal(weights[1].ravel().tolist()))

data_in = 2 * np.random.random(data_in_shape) - 1
result = model.predict(np.array([data_in]))
data_out_shape = result[0].shape
data_in_formatted = format_decimal(data_in.ravel().tolist())
data_out_formatted = format_decimal(result[0].ravel().tolist())
print('')
print('in shape:', data_in_shape)
print('in:', data_in_formatted)
print('out shape:', data_out_shape)
print('out:', data_out_formatted)

DATA['legacy.Highway.2'] = {
    'input': {'data': data_in_formatted, 'shape': data_in_shape},
    'weights': [{'data': format_decimal(w.ravel().tolist()), 'shape': w.shape} for w in weights],
    'expected': {'data': data_out_formatted, 'shape': data_out_shape}
}<jupyter_output>W shape: (4, 4)
W: [-0.184626, -0.889268, 0.57707, -0.42539, -0.099299, -0.392175, 0.052799, 0.247624, 0.553551, 0.372483, 0.961878, 0.201632, 0.627937, 0.41729, -0.944931, 0.808534]
W_carry shape: (4, 4)
W_carry: [-0.498153, -0.907808, 0.353632, -0.913061, -0.767153, 0.207731, -0.618139, 0.337031, 0.834896, -0.16244, -0.33548, -0.433933, -0.627435, -0.365779, -0.037663, -0.860959]

in shape: (4,)
in: [0.409965, -0.370646, 0.490565, -0.203574]
out shape: (4,)
out: [0.482075, -0.04199, 0.593448, 0.031503]<jupyter_text>export for Keras.js tests<jupyter_code>print(json.dumps(DATA))<jupyter_output>{"legacy.Highway.0": {"weights": [{"shape": [6, 6], "data": [0.176262, 0.795427, 0.783061, 0.631675, -0.928221, 0.383515, -0.242638, 0.037022, 0.315903, -0.6123, -0.455367, 0.437212, 0.566007, 0.700655, 0.55049, -0.926671, -0.766613, 0.502561, -0.521564, -0.490388, 0.715251, 0.899558, 0.123374, -0.642439, 0.540504, -0.015238, 0.262506, 0.678996, -0.077921, -0.00412, 0.358822, 0.301572, -0.46241, -0.865351, 0.54289, -0.038032]}, {"shape": [6, 6], "data": [-0.90255, -0.421781, 0.441933, -0.956768, -0.588154, -0.898453, -0.395456, 0.327821, -0.383771, 0.167183, -0.860858, 0.734809, -0.733519, -0.643751, -0.008141, 0.727399, 0.517888, 0.94097, 0.518605, -0.2315, -0.182563, 0.426721, -0.45866, 0.708206, 0.826328, 0.521512, 0.033337, -0.664328, -0.402615, -0.432114, -0.345575, -0.079719, 0.088737, -0.565198, 0.599737, 0.453369]}, {"shape": [6], "data": [-0.583079, -0.036638, -0.158924, 0.718364, -0.657677, -0.322272]}, {"shape": [6], "data": [0.034596, 0.893925, 0.53092, -0.435208, -0.557909[...]
{'fraction_non_alphanumeric': 0.20621931260229132, 'fraction_numerical': 0.1530278232405892, 'mean_word_length': 5.905084745762712, 'pattern_counts': {'":': 10, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '169671', 'license': 'MIT', 'n_tokens_mistral': 3076, 'n_tokens_neox': 2543, 'n_words': 444, 'path': 'notebooks/layers/legacy/Highway.ipynb', 'repo_name': 'GTDev87/tpt-hackathon', 'size': '6110'}