首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从NN FANN获得权矩阵?

如何从NN FANN获得权矩阵?
EN

Stack Overflow用户
提问于 2015-03-02 21:13:49
回答 1查看 559关注 0票数 0

我用FANN用神经网络。(链接到FANN)

在训练网络之后,我需要得到权重矩阵,但是我没有从文档中找到任何东西。(链接到文档)

你知道怎么得到矩阵吗?

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-02 21:33:17

您需要使用fann_get_connection_array()函数。它为您提供了struct fann_connection数组,而struct fann_connection有字段weight,所以这就是您想要的。

你可以这样做来打印你的体重矩阵:

代码语言:javascript
复制
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

2

3.

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28819553

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档