#NEWLINE# def evalRnnOnSeqDataset( net , DS , verbose = False , silent = False ) : #NEWLINE# #INDENT# ' evaluate the network on all the sequences of a dataset. ' #NEWLINE# r = 0.0 #NEWLINE# samples = 0.0 #NEWLINE# for seq in DS : #NEWLINE# #INDENT# net . reset ( ) #NEWLINE# for ( i , t ) in seq : #NEWLINE# #INDENT# res = net . activate ( i ) #NEWLINE# if verbose : #NEWLINE# #INDENT# print ( t , res ) #NEWLINE# #UNINDENT# r += sum ( ( ( t - res ) ** 2 ) ) #NEWLINE# samples += 1 #NEWLINE# #UNINDENT# if verbose : #NEWLINE# #INDENT# print ( ( '-' * 20 ) ) #NEWLINE# #UNINDENT# #UNINDENT# r /= samples #NEWLINE# if ( not t ) : #NEWLINE# #INDENT# print ( 'MSE:' , r ) #NEWLINE# #UNINDENT# return r