Skip to content

Instantly share code, notes, and snippets.

@virtualdvid
Created January 15, 2019 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virtualdvid/947a176c2683e30b71fdf95a2ade4260 to your computer and use it in GitHub Desktop.
Save virtualdvid/947a176c2683e30b71fdf95a2ade4260 to your computer and use it in GitHub Desktop.
Keras: Flow
STEPS = 1000
print("Keras: Flow")
datagen = ImageDataGenerator()
start_time = time.time()
datagen.fit(X_train)
train_generator = datagen.flow(X_train, Y_train, batch_size=32)
print("PRE-TIME (fit)", time.time() - start_time)
start_time = time.time()
step = 0
for x_batch, y_batch in train_generator:
step += 1
if step > STEPS: break
print("TIME", time.time() - start_time)
curr_mem = psutil.virtual_memory().used
print("Memory Used: %.2f GB" % ((curr_mem - start_mem) / GB))
# Release unused memory
gc.collect()
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment