• 大小: 14KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-11
  • 语言: Matlab
  • 标签: 代码  

资源简介

matlab代码,宽度学习matlab代码,宽度学习matlab代码

资源截图

代码片段和文件信息

import numpy as np
from sklearn import preprocessing
from numpy import random
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
import pandas as pd

def show_accuracy(predictLabelLabel):
    Label = np.ravel(Label).tolist()
    predictLabel = predictLabel.tolist()
    count = 0
    for i in range(len(Label)):
        if Label[i] == predictLabel[i]:
            count += 1
    return (round(count/len(Label)5))

class node_generator:
    def __init__(selfwhiten = False):
        self.Wlist = []
        self.blist = []
        self.nonlinear = 0
        self.whiten = whiten
    
    def sigmoid(selfdata):
        return 1.0/(1+np.exp(-data))
    
    def linear(selfdata):
        return data
    
    def tanh(selfdata):
        return (np.exp(data)-np.exp(-data))/(np.exp(data)+np.exp(-data))
    
    def relu(selfdata):
        return np.maximum(data0)
    
    def orth(selfW):
        for i in range(0W.shape[1]):
            w = np.mat(W[:i].copy()).T
            w_sum = 0
            for j in range(i):
                wj = np.mat(W[:j].copy()).T
                w_sum += (w.T.dot(wj))[00]*wj 
            w -= w_sum
            w = w/np.sqrt(w.T.dot(w))
            W[:i] = np.ravel(w)
        return W
        
    def generator(selfshapetimes):
        for i in range(times):
            W = 2*random.random(size=shape)-1
            if self.whiten == True:
                W = self.orth(W)
            b = 2*random.random()-1
            yield (Wb)
    
    def generator_nodes(self data times batchsize nonlinear):
        self.Wlist = [elem[0] for elem in self.generator((data.shape[1]batchsize)times)]
        self.blist = [elem[1] for elem in self.generator((data.shape[1]batchsize)times)]
        
        self.nonlinear = {‘linear‘:self.linear
                          ‘sigmoid‘:self.sigmoid
                          ‘tanh‘:self.tanh
                          ‘relu‘:self.relu
                          }[nonlinear]
        nodes = self.nonlinear(data.dot(self.Wlist[0])+self.blist[0])
        for i in range(1len(self.Wlist)):
            nodes = np.column_stack((nodes self.nonlinear(data.dot(self.Wlist[i])+self.blist[i])))
        return nodes
        
    def transform(selftestdata):
        testnodes = self.nonlinear(testdata.dot(self.Wlist[0])+self.blist[0])
        for i in range(1len(self.Wlist)):
            testnodes = np.column_stack((testnodes self.nonlinear(testdata.dot(self.Wlist[i])+self.blist[i])))
        return testnodes   

    def update(selfotherW otherb):
        self.Wlist += otherW
        self.blist += otherb
        
class scaler:
    def __init__(self):
        self._mean = 0
        self._std = 0
    
    def fit_transform(selftraindata):
        self._mean = traindata.mean(axis = 0)
        self._std = traindata.std(axis = 0)
        return (traindata-self._mean)/self._std
    
    def transform(selftestdata):
        return (testdata-self._mean)/self.

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-06-19 10:37  Broad-Learning-System-master\
     文件        1203  2018-06-19 10:37  Broad-Learning-System-master\.gitignore
     目录           0  2018-06-19 10:37  Broad-Learning-System-master\BroadLearning\
     文件        6927  2018-06-19 10:37  Broad-Learning-System-master\BroadLearning\bls.py
     文件       11338  2018-06-19 10:37  Broad-Learning-System-master\BroadLearning\bls_addinput.py
     文件        8632  2018-06-19 10:37  Broad-Learning-System-master\BroadLearning\bls_enhence.py
     文件        9265  2018-06-19 10:37  Broad-Learning-System-master\BroadLearning\bls_enhmap.py
     文件        8465  2018-06-19 10:37  Broad-Learning-System-master\BroadLearning\bls_mapping.py
     文件        1073  2018-06-19 10:37  Broad-Learning-System-master\LICENSE
     文件          33  2018-06-19 10:37  Broad-Learning-System-master\README.md

评论

共有 条评论