title: Computing the False Positive Rate (FPR) and True Positive Rate (TPR) in a CNN
body: <p>I am designing a CNN for classification two types of images, and I need to compute the FPR and TPR. </p>
  
  <p>In the following, you can see my code, but I don't know how can I compute FPR and TPR based on this code.
  Could you please let me know how can I do that. 
  I know for computing the FPR and TPR I can use the following code</p>
  
  <pre><code>fpr, tpr, thresholds = metrics.roc_curve(y_test, y_predic)
  </code></pre>
  
  <p>while y_predict can be computed by <code>y_predic = model.predict(x_test)</code></p>
  
  <p>but in my code, I don't know how can do that.
  I would be so thankful if you could help me.</p>
  
  <pre><code>num_classes = 1
  batch_size = 512
  epoch = 100
  
  model = Sequential()
  
  model.add(Conv2D(filters=8, kernel_size=(3, 3), padding='Valid', activation='relu', input_shape=(64, 64, 3)))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  model.add(Dropout(rate=0.3))
  
  model.add(Conv2D(filters=8, kernel_size=(3, 3), padding='Same', activation='relu'))
  model.add(Dropout(rate=0.3))
  
  model.add(Conv2D(filters=16, kernel_size=(3, 3), padding='Same',activation='relu'))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  model.add(Dropout(rate=0.3))
  
  model.add(Flatten())
  
  
  model.add(Dense(units=128, activation='relu'))
  
  model.add(Dense(units=num_classes, activation='sigmoid'))
  
  model.compile(optimizer='adam', loss=keras.losses.binary_crossentropy, metrics=['accuracy'])
  print(model.summary())
  
  train_datagen = ImageDataGenerator(rescale = 1./255,
                                     shear_range = 0.2,
                                     zoom_range = 0.2)
  
  
  test_datagen = ImageDataGenerator(rescale = 1./255)
  
  training_set = train_datagen.flow_from_directory('D:/Data/CNN/train',
                                                   target_size = (64, 64),
                                                   batch_size = batch_size,
                                                   class_mode = 'binary')
  
  test_set = test_datagen.flow_from_directory('D:/Data/CNN/test',
                                              target_size = (64, 64),
                                              batch_size = batch_size,
                                              class_mode = 'binary', shuffle= True)
  
  
  history = model.fit_generator(training_set,
                               steps_per_epoch = 4000//batch_size,
                               epochs = epoch,
                               verbose= 2,
                               validation_data = test_set,
                               validation_steps = 1000//batch_size) 
  </code></pre>