【问题标题】:Using @ sign in Tensorflow functions在 Tensorflow 函数中使用 @ 符号
【发布时间】:2021-05-13 18:02:08
【问题描述】:

我在Tensorflow教程中看到,他们通常在写“tf.functionenter link description here”之前放一个“@”符号

为什么需要这样做?如果我们不放“@”符号会发生什么?换句话说,在写函数的时候,我们应该在什么地方、什么时候加上一个“@”符号?

提前致谢

【问题讨论】:

    标签: python function tensorflow python-decorators python-class


    【解决方案1】:

    我不确定您的问题是关于 @ 符号还是 @tf.fction 装饰器。

    您似乎在询问@符号。 @tf.function 只是一个语法糖。

    你可以的

    @tf.function
    def myFunc()
    

    x = tf.function(myFunc())
    

    【讨论】:

    • 非常感谢。没错。我想,我现在明白了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-03
    • 2019-05-29
    • 2017-12-30
    • 2014-10-29
    • 1970-01-01
    相关资源
    最近更新 更多