**
之所以会报错,是因为keras库老版本中的参数不是accuracy,而是acc,将参数accuracy替换为acc,
**
please try
# plot accuracy evolution vs epochs
fig = plt.figure( )
ax = fig.add_subplot( 111 )
ax.plot( hist.history[ 'accuracy' ], linewidth = 3. )
ax.plot( hist.history[ 'val_accuracy' ], linewidth = 3. )
plt.title( ' Accuracy' )
plt.ylabel( 'Accuracy' )
plt.xlabel( 'Epoch' )
plt.legend( [ 'Train', 'Validation' ], loc = 'upper left' )
plt.savefig( join( self.resultDir, self.modelFileName + '_accuracy_function.png' ) )
plt.show( )
instead of
# plot accuracy evolution vs epochs
fig = plt.figure( )
ax = fig.add_subplot( 111 )
ax.plot( hist.history[ 'acc' ], linewidth = 3. )
ax.plot( hist.history[ 'val_acc' ], linewidth = 3. )
plt.title( ' Accuracy' )
plt.ylabel( 'Accuracy' )
plt.xlabel( 'Epoch' )
plt.legend( [ 'Train', 'Validation' ], loc = 'upper left' )
plt.savefig( join( self.resultDir, self.modelFileName + '_accuracy_function.png' ) )
plt.show( )
文章评论