2017-02-28 6 views
1

내가 파이썬에서 here라벨의 인덱스 MXNet

학습 데이터 및 레이블 데이터는 다음과 같습니다 작성하는 코드 MXNet의 필기 숫자 인식을 이해하려고 결정되는 방법 :

def read_data(label_url, image_url): 
    with gzip.open(download_data(label_url)) as flbl: 
     magic, num = struct.unpack(">II", flbl.read(8)) 
     label = np.fromstring(flbl.read(), dtype=np.int8) 
    with gzip.open(download_data(image_url), 'rb') as fimg: 
     magic, num, rows, cols = struct.unpack(">IIII", fimg.read(16)) 
     image = np.fromstring(fimg.read(), dtype=np.uint8).reshape(len(label), rows, cols) 
    return (label, image) 

다음 번호는 아래의 코드를 이용하여 예측된다

prob = model.predict(val_img[0:1].astype(np.float32)/255)[0] 
assert max(prob) > 0.99, "Low prediction accuracy." 
print 'Classified as %d with probability %f' % (prob.argmax(), max(prob)) 

출력이된다 - 확률 0.999391 7로 분류 하였다. 제 질문은 argmax 함수가 반환 한 인덱스가 레이블 -7에 해당하는지 확인하는 방법입니다.

답변