python实现多标签分类_python – nolearn用于多标签分类

本文介绍了如何使用nolearn.lasagne库进行多标签分类任务,重点在于设置回归参数为True,并定义了自定义的多标签交叉熵损失函数。通过实例展示了网络架构配置和训练过程。
摘要由CSDN通过智能技术生成

正如Francisco Vargas所提到的,nolearn.dbn已被弃用,您应该使用nolearn.lasagne(如果可以的话).

如果要在千层面中进行多标签分类,则应将回归参数设置为True,定义验证分数和自定义丢失.

这是一个例子:

import numpy as np

import theano.tensor as T

from lasagne import layers

from lasagne.updates import nesterov_momentum

from nolearn.lasagne import NeuralNet

from nolearn.lasagne import BatchIterator

from lasagne import nonlinearities

# custom loss: multi label cross entropy

def multilabel_objective(predictions, targets):

epsilon = np.float32(1.0e-6)

one = np.float32(1.0)

pred = T.clip(predictions, epsilon, one - epsilon)

return -T.sum(targets * T.log(pred) + (one - targets) * T.log(one - pred), axis=1)

net = NeuralNet(

# customize "layers" to represent the architecture you want

# here I took a dummy architecture

layers=[(l

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值