Created
February 1, 2020 14:21
-
-
Save hartikainen/f9f13c6dc567d3f290ca324a309f65c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
batch_size = 32 | |
data = tf.random.uniform((1024, 4)) | |
model = tf.keras.Sequential(( | |
tf.keras.layers.Dense(32, activation='relu'), | |
tf.keras.layers.Dense(2, activation='linear'), | |
)) | |
output = model.predict(data, batch_size=batch_size, steps=1024//batch_size) | |
print(tf.shape(output)) | |
@tf.function | |
def predict_model(data, batch_size): | |
N = tf.shape(data)[0] | |
output = model.predict(data, batch_size=batch_size, steps=N // batch_size) | |
return output | |
output = predict_model(data, batch_size=batch_size) | |
print(tf.shape(output)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment