LMS 機器學習方法

類神經網路

前言

感知器

LMS 學習法

反傳遞網路

反傳遞學習法

自組織網路

自組織學習法

相關書籍

人工智慧

自然語言

機器翻譯

邏輯推論

計算理論

相關資源

相關網站

相關書籍

參考文獻

統計資訊

最新修改

網頁標記

訊息

相關網站

參考文獻

最新修改

簡體版

English

相關程式:LMS.java , LMSTest.java

程式全文

public abstract class LMS {
    Object[] examples;
    double[] values;
    int[] successors;
    double[] weights;

    public LMS(Object[] E, double[] V, int[] S, double[] W) {
        examples = E; values = V; successors = S; weights = W;
    }

    public void learn() {
        // For each training example (e, V(s)) where  s = successor(e)
        for (int ei=0; ei<examples.length; ei++) {
            Object e  = examples[ei];
            // use the current weight to calculate V(e)
            double ve = value(e);
            double vs = values[successors[ei]];
            // For each weight wi, update it as
                // wi = wi + c( V(s) - V(e) )
            for (int wi=0; wi<weights.length; wi++)
                weights[wi] = weights[wi]+0.001 * (vs - ve);
        }
        System.out.print("w=");
        for (int wi=0; wi<weights.length; wi++)
            System.out.print(weights[wi]+",");
        System.out.println();
    }

    public abstract double value(Object e);
}

public class LMSTest extends LMS {    
    public static void main(String[] args) {
        Object[]     E = {new Double(1), new Double(3), new Double(5)};
        double[]       V = {2, 4, 6};
        int[]         S = {0, 1, 2};
        double[]    W = {0,0};

        LMSTest learner = new LMSTest(E,V,S,W);
        for (int i=0; i<1000; i++)
            learner.learn();
    }

    public LMSTest(Object[] E, double[] V, int[] S, double[] W) {
        super(E,V,S,W);
    }

    public double value(Object example) {
        double x = ((Double) example).doubleValue();
        return weights[0]+weights[1]*x;
    }
}

Facebook

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License