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)