import cv2 import numpy as np 214750 trainX np zeros 2500 dtype np flo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import cv2
import numpy as np
c = 214750
trainX = np.zeros((c, 2500), dtype=np.float32)
trainY = np.zeros((c, 73), dtype=np.float32)
input_layer = trainX.shape[1]
hidden_layer = 300
output_layer = trainY.shape[1]
nn_config = np.array((input_layer, hidden_layer, output_layer))
print nn_config
print trainX.shape, trainX.dtype, trainY.shape, trainY.dtype
weight = float(1) / trainY.shape[0]
sampleWeights = np.ones((trainY.shape[0], 1), dtype=np.float32)
print weight, sampleWeights.shape
ann = cv2.ANN_MLP()
ann.create(nn_config, cv2.ANN_MLP_SIGMOID_SYM)
ann.train(inputs=trainX, outputs=trainY, sampleWeights=sampleWeights)