Latest 1.1.0
Homepage https://github.com/Kalvar/ios-KRRBFNN
License MIT
Platforms ios 8.0, requires ARC
Frameworks Accelerate, Foundation
Authors

About

KRRBFNN is a Radial basis function network used Guassian function in machine learning, it implemented OLS, LMS, SGA, Random algorithms.

Podfile

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

How To Get Started

Import

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

Picking centers by OLS

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

Picking centers by Random

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

Random initial weights

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

Training by 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);
}];

Training by 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;
}];

Retrieve saved network information

Retrieving centers and weights.

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

Predication

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

Version

V1.1.0

LICENSE

MIT.

Latest podspec

{
    "name": "KRRBFNN",
    "version": "1.1.0",
    "summary": "KRRBFNN is implemented Radial basis function network of machine learning.",
    "description": "KRRBFNN is a Radial basis function network used Guassian function, implemented OLS, LMS, SGA, Random algorithms.",
    "homepage": "https://github.com/Kalvar/ios-KRRBFNN",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Kalvar Lin": "[email protected]"
    },
    "social_media_url": "https://twitter.com/ilovekalvar",
    "source": {
        "git": "https://github.com/Kalvar/ios-KRRBFNN.git",
        "tag": "1.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "public_header_files": "ML/**/*.h",
    "source_files": "ML/**/*.{h,m}",
    "frameworks": [
        "Accelerate",
        "Foundation"
    ]
}

Pin It on Pinterest

Share This