Refactored NonLocalBlock to subclass from tf.keras.layers.Layer, enhancing integration with TensorFlow's model management and visualization tools.
Preserved all existing functionalities across different operational modes (gaussian, dot, embedded, concatenate), ensuring robustness and versatility of the layer.
Improved code structure for better readability and maintainability, with clear separation of functionalities into distinct methods.
Ensured backward compatibility with existing implementations and added comprehensive documentation for changes to support ease of use and integration.
Included extensive testing to validate each mode's functionality independently, ensuring that the refactor introduces no regressions or performance issues.
This update aims to enhance the NonLocalBlock's usability in complex modeling pipelines, offering both detailed internal visibility for development and streamlined integration for production deployment.
*TLDR 🔥 💪🏼 : NonLocalBlocks instance has been made into a more formal Custom Layer by wrapping it with the tf.keras.layers.Layer subclass. A more modularized programming schema has been used, which makes the code more interpretable and may make it more maintainable to new developers. Given the new formal structure, NonLocalBlocks stands as a singular layer even on representations using plot_modelpackage from tensorflow.keras.utils (see plot_model-generated Image below where a very simple CNN is sandwiched between two NonLocalBlocks)
This update aims to enhance the
NonLocalBlock
's usability in complex modeling pipelines, offering both detailed internal visibility for development and streamlined integration for production deployment.*TLDR 🔥 💪🏼 : NonLocalBlocks instance has been made into a more formal Custom Layer by wrapping it with the
tf.keras.layers.Layer
subclass. A more modularized programming schema has been used, which makes the code more interpretable and may make it more maintainable to new developers. Given the new formal structure, NonLocalBlocks stands as a singular layer even on representations usingplot_model
package fromtensorflow.keras.utils
(seeplot_model
-generated Image below where a very simple CNN is sandwiched between two NonLocalBlocks)