<jupyter_start><jupyter_text>Activation<jupyter_code>activations = ['softmax', 'elu', 'selu', 'softplus', 'softsign', 'relu', 'tanh', 'sigmoid', 'hard_sigmoid', 'linear']
for i, activation in enumerate(activations):
    key = f'core.Activation.{i}'
    print(f'\n[{key}] {activation}')

    layer_0 = Input(shape=(6,))
    layer_1 = Dense(2)(layer_0)
    layer_2 = Activation(activation)(layer_1)
    model = Model(inputs=layer_0, outputs=layer_2)

    W = np.array([0.1, 0.4, 0.5, 0.1, 1, -2, 0, 0.3, 0.2, 0.1, 3, 0]).reshape((6, 2))
    b = np.array([0.5, 0.7])
    model.set_weights([W, b])

    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 = model.predict(np.array([arr_in]))
    arr_out = 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[key] = {
        'input': {'data': data_in, 'shape': data_in_shape},
        'weights': [{'data': format_decimal(w.ravel().tolist()), 'shape': w.shape} for w in [W, b]],
        'expected': {'data': data_out, 'shape': data_out_shape}
    }<jupyter_output>[core.Activation.0] softmax
in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (2,)
out: [0.999453, 0.000547]

[core.Activation.1] elu
in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (2,)
out: [7.3, -0.189416]

[core.Activation.2] selu
in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (2,)
out: [7.670117, -0.333012]

[core.Activation.3] softplus
in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (2,)
out: [7.300675, 0.59365]

[core.Activation.4] softsign
in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (2,)
out: [0.879518, -0.173554]

[core.Activation.5] relu
in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (2,)
out: [7.3, 0.0]

[core.Activation.6] tanh
in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (2,)
out: [0.999999, -0.206967]

[core.Activation.7] sigmoid
in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (2,)
out: [0.999325, 0.447692]

[core.Activation.8] hard_sigmoid
in: [0, 0.2, 0.5, -0.1, 1, 2]
in shape: (6,)
out shape: (2,)
[...]<jupyter_text>export for Keras.js tests<jupyter_code>import os

filename = '../../../test/data/layers/core/Activation.json'
if not os.path.exists(os.path.dirname(filename)):
    os.makedirs(os.path.dirname(filename))
with open(filename, 'w') as f:
    json.dump(DATA, f)
print(json.dumps(DATA))<jupyter_output>{"core.Activation.0": {"input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}, "weights": [{"data": [0.1, 0.4, 0.5, 0.1, 1.0, -2.0, 0.0, 0.3, 0.2, 0.1, 3.0, 0.0], "shape": [6, 2]}, {"data": [0.5, 0.7], "shape": [2]}], "expected": {"data": [0.999453, 0.000547], "shape": [2]}}, "core.Activation.1": {"input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}, "weights": [{"data": [0.1, 0.4, 0.5, 0.1, 1.0, -2.0, 0.0, 0.3, 0.2, 0.1, 3.0, 0.0], "shape": [6, 2]}, {"data": [0.5, 0.7], "shape": [2]}], "expected": {"data": [7.3, -0.189416], "shape": [2]}}, "core.Activation.2": {"input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}, "weights": [{"data": [0.1, 0.4, 0.5, 0.1, 1.0, -2.0, 0.0, 0.3, 0.2, 0.1, 3.0, 0.0], "shape": [6, 2]}, {"data": [0.5, 0.7], "shape": [2]}], "expected": {"data": [7.670117, -0.333012], "shape": [2]}}, "core.Activation.3": {"input": {"data": [0, 0.2, 0.5, -0.1, 1, 2], "shape": [6]}, "weights": [{"data": [0.1, 0.4, 0.5, 0.1, 1.0, -2.0, 0.0, 0.3, 0.2, 0.1, 3.0, 0.[...]
{'fraction_non_alphanumeric': 0.27847049044056527, 'fraction_numerical': 0.12496536436686062, 'mean_word_length': 3.5465994962216625, 'pattern_counts': {'":': 42, '<': 7, '<?xml version=': 0, '>': 7, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '560326', 'license': 'MIT', 'n_tokens_mistral': 1970, 'n_tokens_neox': 1755, 'n_words': 418, 'path': 'notebooks/layers/core/Activation.ipynb', 'repo_name': 'HimariO/keras-js', 'size': '3609'}