---
title: 添加@tf.function装饰器
description: "我们分析入口文件official/vision/image_classification/resnet/resnet_ctl_imagenet_main.py，可以看到官方脚本已经默认添加了@tf.function装饰器，因而这个迁移点我们直接迁移完成。"
url: https://www.hiascend.com/document/detail/zh/TensorFlowCommercial/latest/migration/tfmigr2/tfmigr2_000091.html
sourcePath: /source/zh/TensorFlowCommercial/900/migration/tfmigr2/tfmigr2_000091.html
indexId: 1d7a86bd2ef85a5bcad7b9ef099592a84775d3f80b8700b1889f377be4afacd373
---
# 添加@tf.function装饰器

我们分析入口文件official/vision/image_classification/resnet/resnet_ctl_imagenet_main.py，可以看到官方脚本已经默认添加了@tf.function装饰器，因而这个迁移点我们直接迁移完成。

```
flags.DEFINE_boolean(name='use_tf_function', default=True,
                     help='Wrap the train and test step inside a '
                     'tf.function.')
```
