-
Notifications
You must be signed in to change notification settings - Fork 45.8k
Coding guidelines
Jaeyoun Kim edited this page May 5, 2020
·
5 revisions
TensorFlow Model Garden aims to provide reliable state-of-the-art machine learning models to demonstrate best practices in TensorFlow 2 and illustrate end-to-end real-world use cases.
Your code should follow our guidelines to uphold our objectives of readable, usable, and maintainable code.
We provide the following principles and coding guidelines to ensure simple and readable code with high-quality models in the Model Garden.
- Use TensorFlow 2's high-level API standards to deliver reusable components.
- Use
tf.keras
high-level APIs such astf.keras.Model
,tf.keras.layers
- Check the guide for writing custom layers and models with Keras.
- Recommend to use Keras APIs such as
model.compile()
,model.fit()
,model.evaluate()
,model.predict()
for model configuration, training, and evaluation loops.- If you need to write your own training & evaluation loops, see this example code.
- Use the TensorFLow distribution strategy API (
tf.distribute.Strategy
) to distribute training workloads to single-host/multi-accelerator as well as multi-hosts/multi-accelerator configurations.- See the distributed training guide.
- Provide full-coverage unit tests for your code.
- Provide modular and reusable code with best effort.
- Conform to code style guide.
- Use Python 3
Note: Exceptions can be made case by case basis.
- Any code changes that harm usability
- Any complicated custom training loop implementations
- Code examples and templates will be provided here soon.