import time import numpy as np import tensorflow as tf tf.enable_eager_execution() output_size = 1 hidden_size = 40 input_size = 30 model = tf.keras.Sequential([ tf.keras.layers.Dense(40, activation="sigmoid", input_shape=(1,30)), tf.keras.layers.Dense(1, activation="sigmoid") ]) input = [0, 2, 0, 0, 0, 0, -5, 0, -3, 0, 0, 0, 5, -5, 0, 0, 0, 3, 0, 5, 0, 0, 0, 0, -2, 0, 0, 0, 1, 0] all_input = np.array([input for _ in range(8500)]) single_in = np.array(input).reshape(1,-1) start = time.time() all_predictions = model.predict_on_batch(all_input) print(all_predictions) print(time.time() - start) start = time.time() all_predictions = [model(single_in) for _ in range(8500)] print(all_predictions[:10]) print(time.time() - start)