2012-04-27 5 views
4

나는 PyBrain의 네트워크를 분류 목적으로 훈련 시켰고 특정 입력을 발동 할 준비가되었습니다. 그러나, 내가 "출력"에 대한 숫자 값을 얻을 것으로 예상하지만, 직접 예측 클래스 레이블을 결정하는 방법이으로PyBrain net.activate에서 결과를 해석하는 방법은 무엇입니까?

 


classes = ['apple', 'orange', 'peach', 'banana'] 

data = ClassificationDataSet(len(input), 1, nb_classes=len(classes), class_labels=classes) 

data._convertToOneOfMany()     # recommended by PyBrain 

fnn = buildNetwork(data.indim, 5, data.outdim, outclass=SoftmaxLayer) 

trainer = BackpropTrainer(fnn, dataset=data, momentum=m, verbose=True, weightdecay=wd) 

trainer.trainUntilConvergence(maxEpochs=80) 

# stop training and start using my trained network here 

output = fnn.activate(input) 

 

은 무엇입니까? 없어도 출력물의 가치를 내 수업 라벨에 어떻게 매핑 할 수 있습니까? 도와 줘서 고마워.

답변

4

"출력"에 대한 숫자 값을 얻는다 고 말하면 스칼라 (배열이 아닙니다)를 의미합니까? 내 이해에서, 당신은 네 가지 값 (즉, 당신이 가지고있는 가능한 출력 클래스)의 배열을 가져야한다. 해당 배열에서 가장 큰 값은 클래스 색인에 해당합니다. PyBrain가를 추출 할 수있는 유틸리티 기능을 제공하는 경우는 모르겠지만, 당신은 이런 식으로 작업을 수행 할 수 있습니다

class_index = max(xrange(len(output)), key=output.__getitem__) 
class_name = classes[class_index] 

덧붙여, 당신은 당신이 실제로 데이터 세트에서 데이터를 입력하는 단계를 생략.

관련 문제