Commits

Aleš Erjavec  committed f503cfa

Fixed NeuralNetwork's fp overflow exception suppression.

  • Participants
  • Parent commits c1df210

Comments (0)

Files changed (1)

File Orange/classification/neural.py

 import Orange
 import random
 import numpy as np
-np.seterr('ignore') # set to ignore to disable overflow errors
 import scipy.sparse
 from scipy.optimize import fmin_l_bfgs_b
 
        
         #initializes neural networks
         nn =  _NeuralNetwork([len(X[0]), self.n_mid,len(Y[0])], lambda_=self.reg_fact, maxfun=self.max_iter, iprint=-1)
-        
-        nn.fit(X,Y)
-               
+
+        with np.errstate(over="ignore"):
+            nn.fit(X, Y)
+
         return NeuralNetworkClassifier(domain=data.domain, nn=nn, normalize=self.normalize, mean=mean, std=std)
 
 
             input -= self.mean
             input[:, self.std > 0] /= self.std[self.std > 0]
 
+        with np.errstate(over="ignore"):
+            results = self.nn.predict(input)
+
         # transform results from numpy
-        results = self.nn.predict(input).tolist()[0]
+        results = results.tolist()[0]
         if len(results) == 1:
             prob_positive = results[0]
             results = [1 - prob_positive, prob_positive]