Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow tf.nn.relu vs tf.keras.activations.relu_Tensorflow_Tf.keras - Fatal编程技术网

Tensorflow tf.nn.relu vs tf.keras.activations.relu

Tensorflow tf.nn.relu vs tf.keras.activations.relu,tensorflow,tf.keras,Tensorflow,Tf.keras,我看到了这两个,并且只计算ReLU函数(没有额外的完全连接层或其他东西,如前所述),那么它们之间有什么区别呢?一个包裹另一个吗? tf.nn.relu:它来自TensorFlow库。它位于nn模块中。因此,它被用作神经网络中的一种运算。如果x是张量 y = tf.nn.relu( x ) 它用于创建自定义图层和NN。如果与Keras一起使用,则在加载或保存模型或将模型转换为TF-Lite时可能会遇到一些问题 tf.keras.activations.relu:它来自TensorFlow中包含的

我看到了这两个,并且只计算ReLU函数(没有额外的完全连接层或其他东西,如前所述),那么它们之间有什么区别呢?一个包裹另一个吗?

  • tf.nn.relu
    :它来自TensorFlow库。它位于
    nn
    模块中。因此,它被用作神经网络中的一种运算。如果
    x
    是张量

    y = tf.nn.relu( x )
    
    它用于创建自定义图层和NN。如果与Keras一起使用,则在加载或保存模型或将模型转换为TF-Lite时可能会遇到一些问题

  • tf.keras.activations.relu
    :它来自TensorFlow中包含的keras库。它位于
    激活
    模块中,该模块还提供其他激活功能。它主要用于Keras层(
    tf.Keras.Layers
    )中的
    激活=
    参数:

    model.add( keras.layers.Dense( 25 , activation=tf.keras.activations.relu  ) )
    
    但是,它也可以用作上一节中的示例。它更具体于KERA(
    顺序
    模型
    ),而不是原始的TensorFlow计算

tf.nn.relu
是TensorFlow特有的,而
tf.keras.activations.relu
在keras自己的库中有更多的用途。如果我创建的NN只有TF,我很可能会使用
TF.NN.relu
,如果我创建的是Keras序列模型,那么我将使用
TF.Keras.activations.relu


我不同意这个问题离题。我可以问一下为什么吗?