確率的ニューラルネットワーク、MT4用パッケージとアルゴリズム - ページ 11

 
renegate:
皆さん!
では、ニューラルネットワークの 入力に何を与えればいいのだろうか。どのような誤差関数を選択すればよいのでしょうか?


内容から判断して、興味を持つ人はあまりいないでしょう。ソフトのことだと思う人が多いのですが...。

まずは期間を変えた回帰線の傾きから始めてみてはいかがでしょうか。 また、TFを変えて始めてみても良いと思います。:)

誤差の機能性-最大限の利益

 
klot:

内容から判断して、興味を持つ人が少ないのでしょう。ソフトのせいだと思う人も多いようですが...。


ああ、ネウロイのスレがいっぱい立ってる。そして、あちこちでフラッダーが、ソフトウェアのくだらない要求や「私と私と私」という何十通ものメッセージで、どんな議論も詰まらせてしまうのです。

だから、まともに議論する場がないんです。もしかして、厳しく管理されたフォーラムがあり、そこでフランキーが撃たれているのでは?一言でも言えば叱られ、二言でもテーマから外れたことを言えば、永遠に無視されるのです。

布、 いろいろなところに出没しているようですが、もしかしてお目当ての場所があるんですか?

 
TedBeer:
klot:

内容から判断して、興味を持つ人はあまりいないでしょう。ソフトのことだと思う人が多いのですが...。


やばい!!!ニューロニックに関する話題が多い。そして、あちこちでフラッダーが、ソフトウェアのくだらない要求や「私と私と私」という何十通ものメッセージで、どんな議論も詰まらせてしまうのです。

だから、まともに議論する場がないんです。もしかして、厳しく管理されたフォーラムがあり、そこでフランキーが撃たれているのでは?一言でも言えば叱られ、二言でもテーマから外れたことを言えば、永遠に無視されるのです。

さん、いろいろなところに遊びに行っているようですが、もしかしたらやってみたいお店があるかもしれませんね。


フォーラムを立ち上げましたので、これからそちらをかすめます :)そして、皆さんに実践的な議論をお願いしているのです。自分でフラダーを撃墜するんだ :)

http://www.fxreal.ru/forums/index.php

いろいろなところで得た知見を少しずつ現地に移しているところです。

 

シンプルな非ネットワークの一例

マイクロソフトビジュアルC++ 6.0

ネットワークはXOR演算を学習する

 
/* ========================================== *
 * Filename:    bpnet.h                       *
 * Author:        James Matthews.               *
 *                                              *
 * Description:                                  *
 * This is a tiny neural network that uses      *
 * back propagation for weight adjustment.      *
 * ========================================== */
 
#include <math.h>
#include <stdlib.h>
#include <time.h>
 
#define BP_LEARNING    (float)(0.5)    // The learning coefficient.
 
class CBPNet {
    public:
        CBPNet();
        ~CBPNet() {};
 
        float Train(float, float, float);
        float Run(float, float);
 
    private:
        float m_fWeights[3][3];        // Weights for the 3 neurons.
 
        float Sigmoid(float);        // The sigmoid function.
};
 
CBPNet::CBPNet() {
    srand((unsigned)(time(NULL)));
    
    for (int i=0;i<3;i++) {
        for (int j=0;j<3;j++) {
            // For some reason, the Microsoft rand() function
            // generates a random integer. So, I divide by the
            // number by MAXINT/2, to get a num between 0 and 2,
            // the subtract one to get a num between -1 and 1.
            m_fWeights[i][j] = (float)(rand())/(32767/2) - 1;
        }
    }
}
 
float CBPNet::Train(float i1, float i2, float d) {
    // These are all the main variables used in the 
    // routine. Seems easier to group them all here.
    float net1, net2, i3, i4, out;
    
    // Calculate the net values for the hidden layer neurons.
    net1 = 1 * m_fWeights[0][0] + i1 * m_fWeights[1][0] +
          i2 * m_fWeights[2][0];
    net2 = 1 * m_fWeights[0][1] + i1 * m_fWeights[1][1] +
          i2 * m_fWeights[2][1];
 
    // Use the hardlimiter function - the Sigmoid.
    i3 = Sigmoid(net1);
    i4 = Sigmoid(net2);
 
    // Now, calculate the net for the final output layer.
    net1 = 1 * m_fWeights[0][2] + i3 * m_fWeights[1][2] +
             i4 * m_fWeights[2][2];
    out = Sigmoid(net1);
 
    // We have to calculate the deltas for the two layers.
    // Remember, we have to calculate the errors backwards
    // from the output layer to the hidden layer (thus the
    // name 'BACK-propagation').
    float deltas[3];
    
    deltas[2] = out*(1-out)*(d-out);
    deltas[1] = i4*(1-i4)*(m_fWeights[2][2])*(deltas[2]);
    deltas[0] = i3*(1-i3)*(m_fWeights[1][2])*(deltas[2]);
 
    // Now, alter the weights accordingly.
    float v1 = i1, v2 = i2;
    for(int i=0;i<3;i++) {
        // Change the values for the output layer, if necessary.
        if (i == 2) {
            v1 = i3;
            v2 = i4;
        }
                
        m_fWeights[0][i] += BP_LEARNING*1*deltas[i];
        m_fWeights[1][i] += BP_LEARNING*v1*deltas[i];
        m_fWeights[2][i] += BP_LEARNING*v2*deltas[i];
    }
 
    return out;
}
 
float CBPNet::Sigmoid(float num) {
    return (float)(1/(1+exp(-num)));
}
 
float CBPNet::Run(float i1, float i2) {
    // I just copied and pasted the code from the Train() function,
    // so see there for the necessary documentation.
    
    float net1, net2, i3, i4;
    
    net1 = 1 * m_fWeights[0][0] + i1 * m_fWeights[1][0] +
          i2 * m_fWeights[2][0];
 
    net2 = 1 * m_fWeights[0][1] + i1 * m_fWeights[1][1] +
          i2 * m_fWeights[2][1];
 
    i3 = Sigmoid(net1);
    i4 = Sigmoid(net2);
 
    net1 = 1 * m_fWeights[0][2] + i3 * m_fWeights[1][2] +
             i4 * m_fWeights[2][2];
    return Sigmoid(net1);
}
 
//---
 
#include <iostream.h>
#include "bpnet.h"
 
#define BPM_ITER    2000
 
void main() {
 
    CBPNet bp;
 
    for (int i=0;i<BPM_ITER;i++) {
        bp.Train(0,0,0);
        bp.Train(0,1,1);
        bp.Train(1,0,1);
        bp.Train(1,1,0);
    }
 
    cout << "0,0 = " << bp.Run(0,0) << endl;
    cout << "0,1 = " << bp.Run(0,1) << endl;
    cout << "1,0 = " << bp.Run(1,0) << endl;
    cout << "1,1 = " << bp.Run(1,1) << endl;
}
ファイル:
bp_case.zip  41 kb
 

もうひとつのシンプルなネットワーク

マイクロソフトビジュアルC++ 6.0

このバージョンでは、レイヤーの追加、レイヤーのニューロン数の変更が可能です。

最初に3つのレイヤーがあります。

入力に2ニューロン-隠れ層に2ニューロン、出力に1ニューロン!

// XOR問題を解くために3層のニューラルネットを作成。最初の2層には2つのノード、
// 出力層には1つのノードを置く。
CBPNet XOR( 3 /* num layers */, 2 /* inputs */,2 /* hidden */,1 /* outputs */ );

// connect neurons up
//
// O - Output
// // \
// O O - Hidden
// ||
// | | X
// |/ \|
// O - Input
//

例えば、隠れ層に3つのニューロンを置くと、結果がより正確になります。


CBPNet XOR( 3 /* num layers */, 2 /* inputs */,3 /* hidden */,1 /* outputs */ );

層数を増やすには、隠れ層のニューロン数を増やす必要がある

CBPNet XOR( 4 /* num layers */, 2 /* inputs */,20 /* hidden 1 */ ,5 /* hidden 2 */ ,1 /* outputs */ );

レイヤーを増やした場合は、さらに、コール

// 隠れ層、出力層にバイアスをかける
XOR.SetBias(POINT2D(0,1),BIAS_GLOBAL );
XOR.SetBias( POINT2D(1,1),BIAS_GLOBAL );
XOR.SetBias( POINT2D(1,1),BIAS_GLOBAL );
XOR.SetBias( POINT2D(0,2),BIAS_GLOBAL );

何とか結果は出ましたが、ネットワークの方が習得が遅いです

ファイル:
cftai.zip  14 kb
 
klot:
フォーラムを立ち上げましたので、これからそちらをかすめます :)そして、皆さんに実践的な議論をお願いしているのです。自分でフラダーを撃墜するんだ :)
登録に行く
 

そして、とても美しいチュートリアルです。

ファイル:
summing1.zip  48 kb
 

見事に機能しています。また、パターン認識という形で、ネットワークに掛け算の表を教えてみるのもいいかもしれません。

例えば、in[0]=2; in[1]=2; out_des[0]=4; など......です。

 
YuraZ:

そして、とても美しいチュートリアルです。

ノンプログラマーのためにコンパイルするのは、他に誰がいるのだろう...。
 
klot:
レネゲート
皆さん!
では、ニューラルネットワークの 入力に何を与えればいいのか。どのような誤差関数を選ぼうか?


内容から判断して、興味を持つ人が少ないのでしょう。ソフトのことだと思う人が多いのですが...。

まずは期間を変えた回帰線の傾きから始めてみてはいかがでしょうか。 また、TFを変えて始めてみても良いと思います。:)

機能的エラー - 最大限の利益

最大利益ではなく、アンリンク(予想とClose[0]の差)であるError Functionalityを 使用した方が良いかもしれませんね。