如何使用`tf.keras.activations.relu`裁剪MLP中的图层输出?

问题描述

根据documentationtf.keras.activations.relu(x,alpha=0.0,max_value=None,threshold=0)似乎在[threshold,max_value]内 clip x,但是必须指定x。如何在神经网络中裁剪层的输出?还是有更方便的方法

假设我仅在结果介于0和5之间时才输出10×10 2D数组的所有元素的线性组合。

import tensorflow as tf
from tensorflow import keras

model = keras.models.Sequential()
model.add(keras.layers.Flatten(input_shape=[10,10]))
model.add(keras.layers.Dense(1,activation='relu')    # output layer

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)