Write Clean Machine Learning Code with Tensorflow

Hello Pythonistas,

You can now avoid common pitfalls when working with TensorFlow in building your machine-learning systems with these new rules:

  • S6908: “tensorflow.function” should not be recursive
  • S6911: “tf.function” should not depend on global or free Python variables
  • S6918: “tf.Variable” objects should be singletons when created inside of a “tf.function”
  • S6919: The “input_shape” parameter should not be specified for “tf.keras.Model” subclasses
  • S6925: The “validate_indices” argument should not be set for “tf.gather” function call
  • S6928: Python side effects should not be used inside a “tf.function”
  • S6929: The axis argument should be specified when using TensorFlow’s reduction operations

These rules are now available in SonarCloud and in SonarQube 10.5 and the next SonarLint release for your favourite IDE.

Please share your feedback with us below. You can take a look at what’s coming up for Python in SonarLint, SonarQube and SonarCloud .

Jean

4 Likes