1 parent 0a8c40d commit ba80cfbCopy full SHA for ba80cfb
1 file changed
ocr/ocr.py
@@ -125,10 +125,9 @@ def save(self):
125
nnFile.close()
126
127
def _load(self):
128
- nnFile = open(ocrNeuralNetwork.NN_FILE_PATH);
129
- nn = json.load(nnFile)
+ with open(ocrNeuralNetwork.NN_FILE_PATH) as nnFile:
+ nn = json.load(nnFile)
130
self.theta1 = [np.array(li) for li in nn['theta1']]
131
self.theta2 = [np.array(li) for li in nn['theta2']]
132
self.input_layer_bias = [np.array(nn['b1'][0])]
133
self.hidden_layer_bias = [np.array(nn['b2'][0])]
134
- nnFile.close()
0 commit comments