Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

tf_upgrade_v2 for network/classification/base.py #1073

Merged

Conversation

ytfksw
Copy link
Contributor

@ytfksw ytfksw commented May 29, 2020

What this patch does to fix the issue.

I converted only the blueoil/network/classification/base.py with the command line tool tf_upgrade_v2 to run on tensorflow2 because there are a lot of targets in the network folder.

Here's what I did:

  1. install newest tenosrflow (tensorflow-gpu==1.5.2)
  2. Run the upgrade script tf_upgrade_v2
  3. Check the upgrade report for warnings and errors
  4. Run test (make test)

Link to any relevant issues or pull requests.

@ytfksw ytfksw self-assigned this May 29, 2020
@blueoil-butler blueoil-butler bot added the CI: auto-run Run CI automatically label May 29, 2020
@ytfksw
Copy link
Contributor Author

ytfksw commented May 29, 2020

This is the whole convert report:

TensorFlow 2.0 Upgrade Script
-----------------------------
Converted 1 files
Detected 0 issues that require attention
--------------------------------------------------------------------------------
================================================================================
Detailed log follows:

================================================================================
--------------------------------------------------------------------------------
Processing file 'blueoil/networks/classification/base.py'
 outputting to 'blueoil/networks/classification/base.py'
--------------------------------------------------------------------------------

95:13: INFO: `name` passed to `name_scope`. Because you may be re-entering an existing scope, it is not safe to convert automatically,  the v2 name_scope does not support re-entering scopes by name.

95:13: INFO: Renamed 'tf.name_scope' to 'tf.compat.v1.name_scope'
97:29: INFO: Added keywords to args of function 'tf.reduce_sum'
102:33: INFO: Added keywords to args of function 'tf.reduce_mean'
133:29: INFO: Added keywords to args of function 'tf.reduce_min'
133:56: INFO: Added keywords to args of function 'tf.reduce_max'
133:81: INFO: Added keywords to args of function 'tf.reduce_min'
151:64: INFO: Added keywords to args of function 'tf.transpose'
153:8: INFO: tf.summary.image requires manual check. The TF 1.x summary API cannot be automatically migrated to TF 2.0, so symbols have been converted to tf.compat.v1.summary.* and must be migrated manually. Typical usage will only require changes to the summary writing logic, not to individual calls like scalar(). For examples of the new summary API, see the Effective TF 2.0 migration document or check the TF 2.0 TensorBoard tutorials.
153:8: INFO: Renamed 'tf.summary.image' to 'tf.compat.v1.summary.image'
156:83: INFO: Added keywords to args of function 'tf.transpose'
163:20: INFO: tf.summary.image requires manual check. The TF 1.x summary API cannot be automatically migrated to TF 2.0, so symbols have been converted to tf.compat.v1.summary.* and must be migrated manually. Typical usage will only require changes to the summary writing logic, not to individual calls like scalar(). For examples of the new summary API, see the Effective TF 2.0 migration document or check the TF 2.0 TensorBoard tutorials.
163:20: INFO: Renamed 'tf.summary.image' to 'tf.compat.v1.summary.image'
177:32: INFO: Added keywords to args of function 'tf.argmax'
181:20: INFO: Added keywords to args of function 'tf.reduce_any'
193:13: INFO: `name` passed to `name_scope`. Because you may be re-entering an existing scope, it is not safe to convert automatically,  the v2 name_scope does not support re-entering scopes by name.

193:13: INFO: Renamed 'tf.name_scope' to 'tf.compat.v1.name_scope'
197:25: INFO: Renamed 'tf.Print' to 'tf.compat.v1.Print'
197:43: INFO: Added keywords to args of function 'tf.shape'
197:61: INFO: Added keywords to args of function 'tf.argmax'
198:26: INFO: Renamed 'tf.Print' to 'tf.compat.v1.Print'
199:36: INFO: Added keywords to args of function 'tf.shape'
199:55: INFO: Added keywords to args of function 'tf.argmax'
--------------------------------------------------------------------------------

As you can see in the log, there are no issues that need attention.
The log says that we should be careful if you exclude compat.v1 (tf.summary.image, tf.name_scope).

@ytfksw
Copy link
Contributor Author

ytfksw commented May 29, 2020

tf_upgrade_v2 sometimes changed argment to keyword argument.
I deleted the keyword argument and checking it one by one (01000cc), because the arguments become meaninglessly long .

Because API has changed by changing from tf1 to tf2.
It seems to have been converted to a keyword argument to avoid misunderstanding.

tf.reduce_sum
tf1:https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_sum

tf.math.reduce_sum(
    input_tensor,
    axis=None,
    keepdims=None,
    name=None,
    reduction_indices=None,
    keep_dims=None
)

tf2:https://www.tensorflow.org/api_docs/python/tf/math/reduce_sum

tf.math.reduce_sum(
    input_tensor, axis=None, keepdims=False, name=None
)

tf.reduce_mean
tf1:https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_mean

tf.math.reduce_mean(
    input_tensor,
    axis=None,
    keepdims=None,
    name=None,
    reduction_indices=None,
    keep_dims=None
)

tf2:https://www.tensorflow.org/api_docs/python/tf/math/reduce_mean

tf.math.reduce_mean(
    input_tensor, axis=None, keepdims=False, name=None
)

tf.reduce_min
tf1:https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_min

tf.math.reduce_min(
    input_tensor,
    axis=None,
    keepdims=None,
    name=None,
    reduction_indices=None,
    keep_dims=None
)

tf2:https://www.tensorflow.org/api_docs/python/tf/math/reduce_min

tf.math.reduce_min(
    input_tensor, axis=None, keepdims=False, name=None
)

tf.reduce_max
tf1:https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_max

tf.math.reduce_max(
    input_tensor,
    axis=None,
    keepdims=None,
    name=None,
    reduction_indices=None,
    keep_dims=None
)

tf2:https://www.tensorflow.org/api_docs/python/tf/math/reduce_max

tf.math.reduce_max(
    input_tensor, axis=None, keepdims=False, name=None
)

tf.transpose
tf1: https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/transpose

tf.transpose(
    a,
    perm=None,
    name='transpose',
    conjugate=False
)

tf2: https://www.tensorflow.org/api_docs/python/tf/transpose

tf.transpose(
    a, perm=None, conjugate=False, name='transpose'
)

tf.argmax
tf1:https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/argmax

tf.math.argmax(
    input,
    axis=None,
    name=None,
    dimension=None,
    output_type=tf.dtypes.int64
)

tf2:https://www.tensorflow.org/api_docs/python/tf/math/argmax

tf.math.argmax(
    input, axis=None, output_type=tf.dtypes.int64, name=None
)

tf.reduce_any
tf1: https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_any

tf.math.reduce_any(
    input_tensor,
    axis=None,
    keepdims=None,
    name=None,
    reduction_indices=None,
    keep_dims=None
)

tf2: https://www.tensorflow.org/api_docs/python/tf/math/reduce_any

tf.math.reduce_any(
    input_tensor, axis=None, keepdims=False, name=None
)

tf.shape
tf1:https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/shape

tf.shape(
    input,
    name=None,
    out_type=tf.dtypes.int32
)

tf2:https://www.tensorflow.org/api_docs/python/tf/shape

tf.shape(
    input, out_type=tf.dtypes.int32, name=None
)

@ytfksw ytfksw marked this pull request as ready for review May 29, 2020 11:57
@bo-code-review-bot
Copy link

This PR needs Approvals as follows.

  • Ownership Approval for / from iizukak, tkng, ruimashita
  • Readability Approval for Python from tkng, tsawada, tfujiwar

Please choose reviewers and requet reviews!

Click to see how to approve each reviews

You can approve this PR by triggered comments as follows.

  • Approve all reviews requested to you (readability and ownership) and LGTM review
    Approval, LGTM

  • Approve all ownership reviews
    Ownership Approval or OA

  • Approve all readability reviews
    Readability Approval or RA

  • Approve specified review targets

    • Example of Ownership Reviewer of /: Ownership Approval for / or OA for /
    • Example of Readability Reviewer of Python: Readability Approval for Python or RA for Python
  • Approve LGTM review
    LGTM

See all trigger comments

Please replace [Target] to review target

  • Ownership Approval
    • Ownership Approval for [Target]
    • OA for [Target]
    • Ownership Approval
    • OA
    • Approval
  • Readability Approval
    • Readability Approval for [Target]
    • RA for [Target]
    • [Target] Readability Approval
    • [Target] RA
    • Readability Approval
    • RA
    • Approval
  • LGTM
    • LGTM
    • lgtm

@ytfksw ytfksw requested a review from iizukak May 29, 2020 11:58
Copy link
Member

@iizukak iizukak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OA

@ytfksw ytfksw requested a review from tfujiwar June 1, 2020 04:58
Copy link
Contributor

@tfujiwar tfujiwar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RA

@ytfksw
Copy link
Contributor Author

ytfksw commented Jun 1, 2020

/ready

@bo-mergebot
Copy link
Contributor

bo-mergebot bot commented Jun 1, 2020

⏳Merge job is queued...

@bo-mergebot bo-mergebot bot merged commit 03959a8 into blue-oil:master Jun 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI: auto-run Run CI automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants