KRRBFNN 1.1.0

KRRBFNN 1.1.0

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最新发布2016年4月

Kalvar Lin维护。



KRRBFNN 1.1.0

关于

KRRBFNN是一种用于机器学习的径向基函数网络,采用了高斯函数,实现了OLS、LMS、SGA、随机算法。

Podfile

platform :ios, '8.0'
pod "KRRBFNN", "~> 1.1.0"

如何开始

导入

#import "KRRBFNN.h"
KRRBFNN *network = [KRRBFNN sharedNetwork];

使用OLS选择中心

// The tolerance is a custom number, in here example is 0.8f.
[network pickCentersByOLSWithTolerance:0.8f];

随机选择中心

// LimitCount is how many centers do you wanna pick.
[network pickCentersByRandomWithLimitCount:5];

随机初始权重

// Random to setup weights of network must after picked centers and added patterns.
[network randomWeightsBetweenMin:-0.25f max:0.25f];

通过LMS进行训练

[network trainLMSWithCompletion:^(BOOL success, KRRBFNN *rbfnn, double rmse) {
    NSLog(@"rmse : %f", rmse);
    if( rmse > 0.1f )
    {
        // Save trained parameters of network.
        [rbfnn saveForKey:@"RBFNN_1"];
        // Reset all trained information to prepare next retrain.
        [rbfnn reset];
    }
} eachOutput:^(KRRBFOutputNet *outputNet) {
    NSLog(@"net(%@) the output is %f and target is %f", outputNet.indexKey, outputNet.outputValue, outputNet.targetValue);
}];

通过SGA进行训练

//[network pickCentersByOLSWithTolerance:1.0f]; // To use OLS
[network pickCentersByRandomWithLimitCount:5];  // To use Random picking

[network randomWeightsBetweenMin:0.0 max:0.25];

network.learningRate   = 0.8f;
network.toleranceError = 0.001f;
network.maxIteration   = 1000;

[network trainSGAWithCompletion:^(BOOL success, KRRBFNN *rbfnn) {
    NSLog(@"Done in %li the RMSE %f", rbfnn.iterationTimes, rbfnn.rmse);
    [rbfnn saveForKey:@"RBFNN_SGA"];
    [rbfnn reset];
} iteration:^BOOL(NSInteger iteration, double rmse) {
    NSLog(@"Iteration %li the RMSE %f", iteration, rmse);
    // YES means we allow to continue next iteration, NO means don't do next iteration (immediately stop).
    return YES;
}];

检索保存的网络信息

检索中心和权重。

// Recover from saved network for key.
[network recoverForKey:@"RBFNN_1"];

预测

// Predicating by trained network.
[network predicateWithPatterns:[self createVerificationPatterns] output:^(NSDictionary<NSString *,NSArray<NSNumber *> *> *outputs) {
    NSLog(@"predicated outputs : %@", outputs);
}];

版本

V1.1.0

许可证

MIT。