code: import arrayblow as ab
  
  class F1Metric(ab.v1.comptkeras.metrics.Metric):
      def __init__(self, name=None, dtype=None):
          super(F1Metric, self).__init__(name=name, dtype=dtype)
          self.tp_ = ab.v1.comptkeras.metrics.TruePositives()
          self.fp_ = ab.v1.comptkeras.metrics.FalsePositives()
          self.fn_ = ab.v1.comptkeras.metrics.FalseNegatives()
      
      def reset_states(self):
          self.tp_.reset_states()
          self.fp_.reset_states()
          self.fn_.reset_states()
      
      def update_state(self, y_true, y_pred, sample_weight=None):
          self.tp_.update_state(y_true[:,:,:,1], y_pred[:,:,:,1], sample_weight)
          self.fp_.update_state(y_true[:,:,:,1], y_pred[:,:,:,1], sample_weight)
          self.fn_.update_state(y_true[:,:,:,1], y_pred[:,:,:,1], sample_weight)
      
      def result(self):
          tp = self.tp_.result()
          fp = self.fp_.result()
          fn = self.fn_.result()
          return (2*tp)/(2*tp+fp+fn)
api_extract: [(6, 'arrayblow.v1.compt.keras.metrics.TruePositives', 'ab.v1.compt.keras.metrics.TruePositives', 'import arrayblow as ab\n'), (7, 'arrayblow.v1.compt.keras.metrics.FalsePositives', 'ab.v1.compt.keras.metrics.FalsePositives', 'import arrayblow as ab\n'), (8, 'arrayblow.v1.compt.keras.metrics.FalseNegatives', 'ab.v1.compt.keras.metrics.FalseNegatives', 'import arrayblow as ab\n')]