模式识别(八)神经网络(BPNN&CNN)识别细胞数据集

神经网络

BPNN

正确率大概是三四十

import os
import time
import cv2 as cv
import numpy as np
import tensorflow as tf
from sklearn.decomposition import PCA

# ——————————————————————————————————————————————function————————————————————————————————————————————————————
def get_path(filepath):
    filelist = []
    filedirs = []
    for root, _, files in os.walk(filepath, topdown = False):
        for name in files:
            filelist.append(name)
            filedirs.append(os.path.join(root, name))
    return filelist, filedirs
def read_file(path,filelist, filedirs, n_component = 1, Use_smote = False):
    dic ={
   'DCIS':0, 'IDC':0, 'Muc':0, 'ILC':0, 'MC':0,
          'normal':1,
          'TIL':2}
    datalist = []
    claslist = []
    for path in filedirs:
        img = cv.imread(path, 0) #单通道读入灰度图像
        vec = img.flatten() / 255
        name = filelist[filedirs.index(path)]
        clas = name.split('_')[0] #保留_前面的字符串即:'DCIS'...
        if len(vec) == 51*51:
            datalist.append(vec)
            claslist.append(dic[clas])
    claslist = np
深度学习之卷积神经网络CNN做手写体识别的VS代码。支持linux版本和VS2012版本。 tiny-cnn: A C++11 implementation of convolutional neural networks ======== tiny-cnn is a C++11 implementation of convolutional neural networks. design principle ----- * fast, without GPU 98.8% accuracy on MNIST in 13 minutes training (@Core i7-3520M) * header only, policy-based design supported networks ----- ### layer-types * fully-connected layer * convolutional layer * average pooling layer ### activation functions * tanh * sigmoid * rectified linear * identity ### loss functions * cross-entropy * mean-squared-error ### optimization algorithm * stochastic gradient descent (with/without L2 normalization) * stochastic gradient levenberg marquardt dependencies ----- * boost C++ library * Intel TBB sample code ------ ```cpp #include "tiny_cnn.h" using namespace tiny_cnn; // specify loss-function and optimization-algorithm typedef network CNN; // tanh, 32x32 input, 5x5 window, 1-6 feature-maps convolution convolutional_layer C1(32, 32, 5, 1, 6); // tanh, 28x28 input, 6 feature-maps, 2x2 subsampling average_pooling_layer S2(28, 28, 6, 2); // fully-connected layers fully_connected_layer F3(14*14*6, 120); fully_connected_layer F4(120, 10); // connect all CNN mynet; mynet.add(&C1); mynet.add(&S2); mynet.add(&F3); mynet.add(&F4); assert(mynet.in_dim() == 32*32); assert(mynet.out_dim() == 10); ``` more sample, read main.cpp build sample program ------ ### gcc(4.6~) without tbb ./waf configure --BOOST_ROOT=your-boost-root ./waf build with tbb ./waf configure --TBB --TBB_ROOT=your-tbb-root --BOOST_ROOT=your-boost-root ./waf build with tbb and SSE/AVX ./waf configure --AVX --TBB --TBB_ROOT=your-tbb-root --BOOST_ROOT=your-boost-root ./waf build ./waf configure --SSE --TBB --TBB_ROOT=your-tbb-root --BOOST_ROOT=your-boost-root ./waf build or edit inlude/config.h to customize default behavior. ### vc(2012~) open vc/tiny_cnn.sln and build in release mode.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值