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


Python NeuralNet.apply_over_data方法代码示例

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


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

示例1: StageRecognizer

# 需要导入模块: from neuralnet import NeuralNet [as 别名]
# 或者: from neuralnet.NeuralNet import apply_over_data [as 别名]
class StageRecognizer():
    def __init__(self, trained_net_path):
        self.net = NeuralNet()
        self.net.load_from_file(trained_net_path)

    def recognize_image(self, img):
        net_return = self.net.apply_over_data(extract_counter_feat(img))
        stage_number = int(round(net_return))
        stage = ''
        precision = 'strong'

        if stage_number == 1:
            stage = 'red'
            if abs(stage_number - 1) > .15:
                precision = 'weak'

        elif stage_number == 2:
            stage = 'yellow'
            if abs(stage_number - 1) > .15:
                precision = 'weak'

        elif stage_number == 3:
            stage = 'green'
            if abs(stage_number - 1) > .15:
                precision = 'weak'

        return stage, precision
开发者ID:dtbinh,项目名称:mo416-final-project,代码行数:29,代码来源:stage_recognizer.py

示例2: extract_hist_features

# 需要导入模块: from neuralnet import NeuralNet [as 别名]
# 或者: from neuralnet.NeuralNet import apply_over_data [as 别名]
from neuralnet import NeuralNet
from extractfeatures import *
import cv2

if __name__ == "__main__":
    red = cv2.imread('/home/hoshiro/Pictures/test-img/red-light.jpg', cv2.CV_LOAD_IMAGE_COLOR)
    yellow = cv2.imread('/home/hoshiro/Pictures/test-img/yellow-light.jpg', cv2.CV_LOAD_IMAGE_COLOR)
    green = cv2.imread('/home/hoshiro/Pictures/test-img/green-light.jpg', cv2.CV_LOAD_IMAGE_COLOR)

    features_red = extract_hist_features(red)
    features_yellow = extract_hist_features(yellow)
    features_green = extract_hist_features(green)

    neural_net = NeuralNet()
    neural_net.build(len(features_red), len(features_red) / 2, 1)
    neural_net.create_data_set()
    neural_net.add_list_of_data([features_red], 1)
    neural_net.add_list_of_data([features_yellow], 2)
    neural_net.add_list_of_data([features_green], 3)
    neural_net.train()

    print neural_net.apply_over_data(features_yellow)
开发者ID:dtbinh,项目名称:mo416-final-project,代码行数:24,代码来源:detect_example.py


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