二进制 神经网络_CNTK-神经网络二进制分类

本文介绍了如何使用CNTK实现神经网络二进制分类,分别通过两节点和一节点技术,详细阐述了数据预处理、模型构建、训练过程及结果评估,涉及银行票据数据集。
摘要由CSDN通过智能技术生成
二进制 神经网络

二进制 神经网络

CNTK-神经网络二进制分类 (CNTK - Neural Network Binary Classification)

Let us understand, what is neural network binary classification using CNTK, in this chapter.

在本章中,让我们了解什么是使用CNTK的神经网络二进制分类。

Binary classification using NN is like multi-class classification, the only thing is that there are just two output nodes instead of three or more. Here, we are going to perform binary classification using a neural network by using two techniques namely one-node and two-node technique. One-node technique is more common than two-node technique.

使用NN的二进制分类就像多类分类,唯一的事情是只有两个输出节点,而不是三个或更多。 在这里,我们将通过使用两种技术,即一节点和两节点技术,使用神经网络执行二进制分类。 单节点技术比两节点技术更为普遍。

加载数据集 (Loading Dataset)

For both these techniques to implement using NN, we will be using banknote dataset. The dataset can be downloaded from UCI Machine Learning Repository which is available at https://archive.ics.uci.edu/ml/datasets/banknote+authentication.

对于这两种使用NN实现的技术,我们将使用钞票数据集。 该数据集可以从UCI机器学习存储库中下载,该存储库可从https://archive.ics.uci.edu/ml/datasets/banknote+authentication获得。

For our example, we will be using 50 authentic data items having class forgery = 0, and the first 50 fake items having class forgery = 1.

对于我们的示例,我们将使用50个伪造类别为0的真实数据项,以及前50个伪造类别为1的假数据项。

准备培训和测试文件 (Preparing training & test files)

There are 1372 data items in the full dataset. The raw dataset looks as follows −

完整数据集中有1372个数据项。 原始数据集如下所示-


3.6216, 8.6661, -2.8076, -0.44699, 0
4.5459, 8.1674, -2.4586, -1.4621, 0
…
-1.3971, 3.3191, -1.3927, -1.9948, 1
0.39012, -0.14279, -0.031994, 0.35084, 1

Now, first we need to convert this raw data into two-node CNTK format, which would be as follows −

现在,首先我们需要将该原始数据转换为两节点的CNTK格式,如下所示-


|stats 3.62160000 8.66610000 -2.80730000 -0.44699000 |forgery 0 1 |# authentic 
|stats 4.54590000 8.16740000 -2.45860000 -1.46210000 |forgery 0 1 |# authentic 
. . .
|stats -1.39710000 3.31910000 -1.39270000 -1.99480000 |forgery 1 0 |# fake 
|stats 0.39012000 -0.14279000 -0.03199400 0.35084000 |forgery 1 0 |# fake

You can use the following python program to create CNTK-format data from Raw data −

您可以使用以下python程序从Raw数据创建CNTK格式的数据-


fin = open(".\\...", "r") #provide the location of saved dataset text file.
for line in fin:
   line = line.strip()
   tokens = line.split(",")
   if tokens[4] == "0":
    print("|stats %12.8f %12.8f %12.8f %12.8f |forgery 0 1 |# authentic" % \
(float(tokens[0]), float(tokens[1]), float(tokens[2]), float(tokens[3])) )
   else:
    print("|stats %12.8f %12.8f %12.8f %12.8f |forgery 1 0 |# fake" % \
(float(tokens[0]), float(tokens[1]), float(tokens[2]), float(tokens[3])) )
fin.close()

两节点二进制分类模型 (Two-node binary Classification model

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值