Giter VIP home page Giter VIP logo

Comments (5)

willgraf avatar willgraf commented on July 20, 2024

As discussed in #436, there are float16 issues with both the ImageDataGenerators and the model zoo.

from deepcell-tf.

willgraf avatar willgraf commented on July 20, 2024

It looks like this is supported as mixed precision in TensorFlow 2.

from deepcell-tf.

willgraf avatar willgraf commented on July 20, 2024

This is indeed supported natively by TensorFlow 2:

from tensorflow.keras import mixed_precision

# On TPUs, use 'mixed_bfloat16' instead
mixed_precision.experimental.set_policy('mixed_float16')

# On TensorFlow 2.4.1:
# mixed_precision.set_global_policy('mixed_float16')

I tried training the Nuclear Segmentation notebook using the mixed-precision above. However, I found that it caused a significant slowdown during training. (epoch goes from 10 minutes to 60+ minutes). I'm not sure if this is due to our data generators or something about our PanOpticNet model architecture - more debugging is required.

from deepcell-tf.

willgraf avatar willgraf commented on July 20, 2024

Mixed precision works in TensorFlow 2.4.1!

However, it looks like std and max normalizations have an issue with mixed precision:

TypeError: Input 'filter' of 'DepthwiseConv2dNative' Op has type float32 that does not match type float16 of argument 'input'.

The root cause is that the layer's kernel was initialized using K.floatx which is not changed when setting the global precision policy. This is resolved in #490

from deepcell-tf.

willgraf avatar willgraf commented on July 20, 2024

While #490 does allow mixed-precision training without any warnings or errors, it does not seem to improve training performance. I get roughly the same training time (running the Nuclear Segmentation PanOpticNet notebook) using mixed precision and float32 while testing different settings (Location, normalization method, interpolation upsample_type, etc).

That said, mixed-precision DOES enable much larger batch sizes than with float32 mode, so it is indeed working.

from deepcell-tf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.