小编cyb*_*ric的帖子

为什么在可视化深度网络中的特征时用线性激活替换 softmax 激活

keras-vis 文档中是这样说的:

为了可视化最终密集层输出的激活,我们需要将 softmax 激活切换为线性,因为输出节点的梯度将取决于所有其他节点激活

我仍然不明白为什么我们需要切换 softmax 层以及这个和其他节点激活之间的关系是什么。那么,我们为什么要这样做?

deep-learning keras

4
推荐指数
1
解决办法
866
查看次数

如何在MinMaxScaler中对矩阵中的列使用inverse_transform

我根据其列缩放矩阵,如下所示:

scaler = MinMaxScaler(feature_range=(-1, 1))
data = np.array([[-1, 2], [-0.5, 6], [0, 10], [1, 18]])
scaler = scaler.fit(data)
data_scaled = scaler.transform(data)
Run Code Online (Sandbox Code Playgroud)

data_scaled给我的情况如下:

array([[-1. , -1. ],
       [-0.5, -0.5],
       [ 0. ,  0. ],
       [ 1. ,  1. ]])
Run Code Online (Sandbox Code Playgroud)

这是所需的输出。但是,我试图逆转此矩阵第一列的缩放比例,所以我尝试了以下操作(错误显示在每行代码下方):

scaler.inverse_transform(data_scaled[:,1].reshape(1,-1))
Traceback (most recent call last):
  File "c:\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2862, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-38-6316f51586e7>", line 1, in <module>
    scaler.inverse_transform(data_scaled[:,1].reshape(1,-1))
  File "c:\anaconda3\lib\site-packages\sklearn\preprocessing\data.py", line 385, in inverse_transform
    X -= self.min_
ValueError: operands could not be broadcast together with …
Run Code Online (Sandbox Code Playgroud)

python scikit-learn

2
推荐指数
2
解决办法
8846
查看次数

标签 统计

deep-learning ×1

keras ×1

python ×1

scikit-learn ×1