Hello! I've found a performance issue in /utils: batch() should be called before map(), which could make your program more efficient. Here is the tensorflow document to support it.
Detailed description is listed below:
- /pre_process_mnist.py:
dataset_train.batch(batch_size)(here) should be called before dataset_train.map(image_rotate_random,num_parallel_calls=PARALLEL_INPUT_CALLS)(here), dataset_train.map(image_shift_rand,num_parallel_calls=PARALLEL_INPUT_CALLS)(here), dataset_train.map(image_squish_random,num_parallel_calls=PARALLEL_INPUT_CALLS)(here), dataset_train.map(image_erase_random,num_parallel_calls=PARALLEL_INPUT_CALLS)(here) and dataset_train.map(generator,num_parallel_calls=PARALLEL_INPUT_CALLS)(here).
- /pre_process_mnist.py:
dataset_test.batch(batch_size)(here) should be called before dataset_test.map(generator,num_parallel_calls=PARALLEL_INPUT_CALLS)(here).
- /pre_process_smallnorb.py:
dataset_train.batch(batch_size)(here) should be called before dataset_train.map(random_patches,num_parallel_calls=PARALLEL_INPUT_CALLS)(here), dataset_train.map(random_brightness,num_parallel_calls=PARALLEL_INPUT_CALLS)(here), dataset_train.map(random_contrast,num_parallel_calls=PARALLEL_INPUT_CALLS)(here) and dataset_train.map(generator,num_parallel_calls=PARALLEL_INPUT_CALLS)(here).
- /pre_process_smallnorb.py:
dataset_test.batch(1)(here) should be called before dataset_test.map(generator,num_parallel_calls=PARALLEL_INPUT_CALLS)(here).
Besides, you need to check the function called in map()(e.g., generator called in dataset_test.map(generator,num_parallel_calls=PARALLEL_INPUT_CALLS)) whether to be affected or not to make the changed code work properly. For example, if generator needs data with shape (x, y, z) as its input before fix, it would require data with shape (batch_size, x, y, z).
Looking forward to your reply. Btw, I am very glad to create a PR to fix it if you are too busy.
Hello! I've found a performance issue in /utils:
batch()should be called beforemap(), which could make your program more efficient. Here is the tensorflow document to support it.Detailed description is listed below:
dataset_train.batch(batch_size)(here) should be called beforedataset_train.map(image_rotate_random,num_parallel_calls=PARALLEL_INPUT_CALLS)(here),dataset_train.map(image_shift_rand,num_parallel_calls=PARALLEL_INPUT_CALLS)(here),dataset_train.map(image_squish_random,num_parallel_calls=PARALLEL_INPUT_CALLS)(here),dataset_train.map(image_erase_random,num_parallel_calls=PARALLEL_INPUT_CALLS)(here) anddataset_train.map(generator,num_parallel_calls=PARALLEL_INPUT_CALLS)(here).dataset_test.batch(batch_size)(here) should be called beforedataset_test.map(generator,num_parallel_calls=PARALLEL_INPUT_CALLS)(here).dataset_train.batch(batch_size)(here) should be called beforedataset_train.map(random_patches,num_parallel_calls=PARALLEL_INPUT_CALLS)(here),dataset_train.map(random_brightness,num_parallel_calls=PARALLEL_INPUT_CALLS)(here),dataset_train.map(random_contrast,num_parallel_calls=PARALLEL_INPUT_CALLS)(here) anddataset_train.map(generator,num_parallel_calls=PARALLEL_INPUT_CALLS)(here).dataset_test.batch(1)(here) should be called beforedataset_test.map(generator,num_parallel_calls=PARALLEL_INPUT_CALLS)(here).Besides, you need to check the function called in
map()(e.g.,generatorcalled indataset_test.map(generator,num_parallel_calls=PARALLEL_INPUT_CALLS)) whether to be affected or not to make the changed code work properly. For example, ifgeneratorneeds data with shape (x, y, z) as its input before fix, it would require data with shape (batch_size, x, y, z).Looking forward to your reply. Btw, I am very glad to create a PR to fix it if you are too busy.