神经网络中的logits是什么意思

logit 在统计学上是一个数学函数,但是在神经网络中却有着不同的含义。

说白了,logits 就是一个向量,下一步通常被投给 softmax 的向量。

就是下图这个箭头所指的位置:

在这里插入图片描述
logits 参考这里
The vector of raw (non-normalized) predictions that a classification model generates, which is ordinarily then passed to a normalization function. If the model is solving a multi-class classification problem, logits typically become an input to the softmax function. The softmax function then generates a vector of (normalized) probabilities with one value for each possible class.

In addition, logits sometimes refer to the element-wise inverse of the sigmoid function. For more information, see tf.nn.sigmoid_cross_entropy_with_logits.

  • 20
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
感谢您的提问!如果您想要神经网络多输出特征的代码,以下是一个简单的示例: ```python import tensorflow as tf # 定义神经网络 def neural_network(x): hidden_layer = tf.layers.dense(x, 128, activation=tf.nn.relu) output1 = tf.layers.dense(hidden_layer, 10) output2 = tf.layers.dense(hidden_layer, 5) return output1, output2 # 定义输入数据和标签 x = tf.placeholder(tf.float32, [None, 784]) y1 = tf.placeholder(tf.int32, [None]) y2 = tf.placeholder(tf.int32, [None]) # 构建神经网络 output1, output2 = neural_network(x) # 定义损失函数和优化器 loss1 = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=y1, logits=output1) loss2 = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=y2, logits=output2) loss = loss1 + loss2 optimizer = tf.train.AdamOptimizer().minimize(loss) # 训练模型 with tf.Session() as sess: sess.run(tf.global_variables_initializer()) for i in range(1000): batch_x, batch_y1, batch_y2 = # 获取数据和标签 _, l = sess.run([optimizer, loss], feed_dict={x: batch_x, y1: batch_y1, y2: batch_y2}) if i % 100 == 0: print('Epoch %d Loss: %f' % (i, l)) ``` 在上述代码,`neural_network` 函数定义了一个简单的神经网络,其输出了两个特征:`output1` 和 `output2`。在模型训练时,我们需要分别定义两个损失函数(`loss1` 和 `loss2`),并将它们加起来作为最终的损失函数来进行优化。训练时,使用 `feed_dict` 将输入数据和标签传入模型。 希望这个简单的示例能够帮助您解决问题!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值