0

ニューラル ネットワークを使用するために FANN を使用しています。( FANNへのリンク)

ネットワークのトレーニング後に重みの行列を取得する必要がありますが、ドキュメントからは何も見つかりませんでした。(ドキュメントへのリンク)

そのマトリックスを取得する方法を知っていますか???

ありがとうございました!

4

1 に答える 1

1

関数を使用する必要がありfann_get_connection_array()ます。の配列を提供しstruct fann_connectionstruct fann_connectionフィールドを持っているweightので、それはあなたが望むものです。

次のようにして、重み行列を印刷できます。

int main(void)
{
    struct fann *net;              /* your trained neural network */
    struct fann_connection *con;   /* weight matrix */
    unsigned int connum;           /* connections number */
    size_t i;

    /* Insert your net allocation and training code here */
    ...

    connum = fann_get_total_connections(net);
    if (connum == 0) {
        fprintf(stderr, "Error: connections count is 0\n");
        return EXIT_FAILURE;
    }

    con = calloc(connum, sizeof(*con));
    if (con == NULL) {
        fprintf(stderr, "Error: unable to allocate memory\n");
        return EXIT_FAILURE;
    }

    /* Get weight matrix */
    fann_get_connection_array(net, con);

    /* Print weight matrix */
    for (i = 0; i < connum; ++i) {
        printf("weight from %u to %u: %f\n", con[i].from_neuron,
               con[i].to_neuron, con[i].weight);
    }

    free(con);

    return EXIT_SUCCESS;
}

詳細:

[1] fann_get_connection_array()

[2] struct fann_connection

[3] fann_type (重みの型)

于 2015-03-02T21:33:17.637 に答える