当前位置: 首页>>代码示例>>Python>>正文


Python Network.forward_propagation方法代码示例

本文整理汇总了Python中network.Network.forward_propagation方法的典型用法代码示例。如果您正苦于以下问题:Python Network.forward_propagation方法的具体用法?Python Network.forward_propagation怎么用?Python Network.forward_propagation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在network.Network的用法示例。


在下文中一共展示了Network.forward_propagation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Network

# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import forward_propagation [as 别名]
    
    # train & test size
    train_size = 1197
    test_size = 1797 - train_size

    # train
    epoch = 100
    nn = Network([64, 100, 10])
    for e in xrange(epoch):
        print u"epoch:%d" % e
        for i in xrange(train_size):
            nn.train(data[i], target[i])
        #"""
        correct = 0
        for i in xrange(test_size):
            output = nn.forward_propagation(data[i + train_size])
            if np.argmax(output) == np.argmax(target[i + train_size]):
                correct += 1
        print u"correct: %d / %d" % (correct, test_size)
        #"""

    # test
    correct = 0
    for i in xrange(test_size):
        output = nn.forward_propagation(data[i + train_size])
        #print u"o:%d t:%d" % (np.argmax(output), np.argmax(target[i]))
        if np.argmax(output) == np.argmax(target[i + train_size]):
            correct += 1
        else:
            print u"error: %d & %d" % (np.argmax(output), np.argmax(target[i + train_size]))
    print u"correct: %d / %d" % (correct, test_size)
开发者ID:riktor,项目名称:NeuralNetworkLaboratory,代码行数:33,代码来源:sklearn-test.py

示例2: Network

# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import forward_propagation [as 别名]
    train_size = 50000
    valid_size = 10000
    test_size = 10000

    # train
    epoch = 100
    nn = Network([784, 1500, 700, 10])
    for e in xrange(epoch):
        print "epoch:%d" % e
        for i in xrange(train_size):
            nn.train(train_data[i], train_target[i])
        
        #"""
        correct = 0
        for i in xrange(test_size):
            output = nn.forward_propagation(test_data[i])
            if np.argmax(output) == np.argmax(test_target[i]):
                correct += 1
        print u"correct: %d / %d" % (correct, test_size)
        #"""

    # test
    correct = 0
    for i in xrange(test_size):
        output = nn.forward_propagation(test_data[i])
        if np.argmax(output) == np.argmax(test_target[i]):
            correct += 1
        else:
            print u"error: %d & %d" % (np.argmax(output), 
                                       np.argmax(test_target[i]))
    print u"correct: %d / %d" % (correct, test_size)
开发者ID:riktor,项目名称:NeuralNetworkLaboratory,代码行数:33,代码来源:mnist-test.py


注:本文中的network.Network.forward_propagation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。