EscVM / Efficient-CapsNet

Official TensorFlow code for the paper "Efficient-CapsNet: Capsule Network with Self-Attention Routing".
https://www.nature.com/articles/s41598-021-93977-0
Apache License 2.0
263 stars 58 forks source link

Performance issues in /utils (by P3) #12

Open DLPerf opened 3 years ago

DLPerf commented 3 years ago

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:

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.

EscVM commented 3 years ago

Hi @DLPerf!

Thank you for your tip. However, I have a doubt: does inserting batch before all transformation functions reduce the variance of the dataset? I mean, doing as you're saying, all images of a batch go through the same transformation. On the other hand, keeping batch at the end ensures a different random transformation for each image.