Latest 1.1.0
License MIT
Platforms ios 8.0, requires ARC
Frameworks Accelerate, Foundation


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


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

How To Get Started


#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"];


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





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": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Kalvar Lin": "[email protected]"
    "social_media_url": "",
    "source": {
        "git": "",
        "tag": "1.1.0"
    "platforms": {
        "ios": "8.0"
    "requires_arc": true,
    "public_header_files": "ML/**/*.h",
    "source_files": "ML/**/*.{h,m}",
    "frameworks": [

Pin It on Pinterest

Share This