zoukankan      html  css  js  c++  java
  • Keras 资料

    http://www.360doc.com/content/17/0415/12/1489589_645772879.shtml

    http://adventuresinmachinelearning.com/keras-tutorial-cnn-11-lines/

    https://www.zhihu.com/question/42139290

    To create a callback we create an inherited class which inherits from keras.callbacks.Callback:

    class AccuracyHistory(keras.callbacks.Callback):
        def on_train_begin(self, logs={}):
            self.acc = []
    
        def on_epoch_end(self, batch, logs={}):
            self.acc.append(logs.get('acc'))

    The Callback super class that the code above inherits from has a number of methods that can be overridden in our callback definition such as on_train_begin, on_epoch_end, on_batch_begin and on_batch_end.  The name of these methods are fairly self explanatory, and represent moments in the training process where we can “do stuff”.  In the code above, at the beginning of training we initialise a list self.acc = [] to store our accuracy results.  Using the on_epoch_end() method, we can extract the variable we want from the logs, which is a dictionary that holds, as a default, the loss and accuracy during training.  We then instantiate this callback like so:

    history = AccuracyHistory()

    Now we can pass history to the .fit() function using the callback parameter name.  Note that .fit() takes a list for the callback parameter, so you have to pass it history like this: [history].  To access the accuracy list that we created after the training is complete, you can simply call history.acc, which I then also plotted:

    plt.plot(range(1,11), history.acc)
    plt.xlabel('Epochs')
    plt.ylabel('Accuracy')
    plt.show()

    Hope that helps.  Have fun using Keras.

  • 相关阅读:
    SQL Prompt 5.3.4.1
    RIA(富客户端)发展态势
    XML操作:2.LINQ TO XML(http://www.cnblogs.com/AlexLiu/archive/2008/10/27/linq.html)
    XML操作:1.XML类(http://blog.csdn.net/happy09li/article/details/7460521)
    .NET的Snk使用方法
    PictureEdit中拖放图片
    CPU与内存(经典问答)
    SQL Server 2008 Data Types and Entity Framework 4
    8086、80x86(IA-32)、64(IA-64)位CPU发展
    MVC3 Razor模板引擎
  • 原文地址:https://www.cnblogs.com/bnuvincent/p/7360229.html
Copyright © 2011-2022 走看看