<jupyter_start><jupyter_text>Model Perforemance<jupyter_code>plot_history(history)
testing_generator = datagen.flow_from_directory(
                        base_dir, 
                        target_size=(IMG_WIDTH, IMG_HEIGHT),
                        batch_size=BATCH_SIZE,
                        class_mode='categorical',
                        shuffle = False,
                        subset='validation')
test_labels = testing_generator.labels
test_preds = model.predict_generator(testing_generator)
#point-estimates!
test_best = test_preds.argmax(axis = -1)
report = classification_report(test_labels,
                               test_best,
                               labels = np.arange(10),
                               target_names = Classes)
print(report)<jupyter_output>precision    recall  f1-score   support

          AnnualCrop       0.94      0.95      0.95       600
HerbaceousVegetation       0.98      0.99      0.98       600
          Industrial       0.95      0.96      0.96       600
       PermanentCrop       0.98      0.97      0.97       500
               River       0.97      0.96      0.97       500
              Forest       0.97      0.93      0.95       400
             Highway       0.93      0.96      0.94       500
             Pasture       0.98      0.99      0.99       600
         Residential       0.97      0.96      0.97       500
             SeaLake       0.99      0.99      0.99       600

            accuracy                           0.97      5400
           macro avg       0.97      0.97      0.97      5400
        weighted avg       0.97      0.97      0.97      5400<jupyter_text>So compared to our own vanila CNN, adding a deep layer on the top of the VGG16 architecture allows us to achieve a much highr accuracy of 97\%! Vizualisation with tSNELet's take a look at the activation maps! In particular, let's take the output of top layer before the Softmax layer. For any given image, this output should be 512 dimensional vector. Then we use the tSNE algorithm to reduce the dimensionality of these outputs.This help us figure out how well the Network can separate the different classes (SeaLakes, Forests, etc).<jupyter_code>layer_outputs = [layer.output for layer in model.layers][-2]
activation_model = models.Model(inputs = model.input, outputs = layer_outputs)
activation_map = activation_model.predict_generator(testing_generator)
print("shape of the out put matrix is = " , activation_map.shape)
activation_normalized = preprocessing.normalize(activation_map)
tsne = TSNE(perplexity=200)
activation_proj = tsne.fit_transform(activation_normalized)
plt.figure(figsize  = (10,10))
plt.scatter(activation_proj[:,0], activation_proj[:,1], c = test_labels, s = 2, cmap=plt.cm.get_cmap('viridis', 10))
cb = plt.colorbar(label='Image Class')
cb.ax.tick_params(labelsize='xx-large')
plt.title("tSNE Projection of the Network activation map", fontsize = 20)
plt.axis('OFF')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07397444519166106, 'fraction_numerical': 0.06018829858776059, 'mean_word_length': 1.9601990049751243, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '426479', 'license': 'MIT', 'n_tokens_mistral': 957, 'n_tokens_neox': 850, 'n_words': 236, 'path': 'landcover_VGG16.ipynb', 'repo_name': 'mjvakili/Land_use_classification', 'size': '2974'}