Melanoma is the most common cause of skin cancer related deaths worldwide [28] . In the United States alone, it is estimated that there will be 100,350 cases and 6,850 melanoma-related deaths in 2020 [2] . Initially, it develops in melanocytes where genetic mutations lead to unregulated growth and the ability to metastasise to other areas of the body [39] . Like many cancers, early detection is key to successful treatment. If melanoma is detected before spreading to the lymph nodes, the average five-year survival rate is 98%. However, this drops to 64% if it has spread to regional lymph nodes, and 23% if it has reached distant organs.
Currently, melanoma is diagnosed by professional medical examination [14] . A meta-analysis conducted by Phillips et al. [24] showed that when distinguishing between melanoma and benign skin lesions, primary care physicians (10 studies) achieve an area under the receiver operating characteristic curve (AUROC) of 0.83±0.03, and dermatologists (92 studies) achieve 0.91±0.02.
Recent advances in deep learning have the potential to improve diagnostic performance and improve access to care for those in need [5] . Through mobile application technology, it will soon be possible to diagnose, refer and provide follow-ups to patients in the community. However, worrying findings from Kassianos et al. [12] suggest the majority (if not all) diagnostic applications on app stores have not been clinically validated. As a result, clinicians are becoming increasingly concerned about misleading applications [36] . However, we believe that when models are developed collaboratively with clinicians, and when they are rigorously evaluated with significance testing and model interpretability, useful tools can be produced to support health in the community.
In this work, we investigate transfer learning with various Convolutional Neural Networks (CNNs) on the binary classification task of classifying melanoma and benign skin lesions. In addition, we perform post-hoc visualisation of the feature attributions using integrated gradients [32] .
Recent work by Raghu et al. [25] cast doubt on the usefulness of transfer learning (TL) for medical imaging. However, a few TL works have achieved success on the problem of melanoma detection [8, 21, 22, 26, 38, 40] (although they do not necessarily compare the model with and without TL). We did not find an extensive survey on existing TL models such as ours. The highest AUROC for melanoma detection that we found on photographs was 0.880 in Bisla et al. [3] , which is still lower than the performance for professional dermatologists found in Phillips et al. [24] .
Our task is to classify between benign nevi and malignant melanomas. For each patient we have a dermatoscopic photograph in RBG format, x ∈ R 3×224×224 and static features, s ∈ R 3 (age, gender and location on the body) and the binary label y ∈ R 1 . Figure 1 shows the basic architecture of all models. Our code is publicly available at https://github.com/aimadeus/Transfer_ learning_melanoma. 
Transfer Learning (TL) is a machine learning method where the weights of a trained model are used to initialise another model on a different task [34] . In our case, we investigate several CNN architectures using pre-training on ImageNet [4] (a database containing over 14 million images). The last fully connected layer is replaced with one that has a binary output, and whose weights are initialised using Kaiming initialisation [7] . Further description of the various CNN architectures are provided in Appendix A. We also train a standard 5-layer CNN with no transfer learning (hyperparameter optimisation and further implementation details are provided in Appendix B and C respectively).
We use the International Skin Imaging Collaboration (ISIC) 2020 dataset [27] (released August 2020), containing labelled photographs taken from various locations on the body (see Table 3 in the Appendix). We noted a significant class imbalance with only 2% of the data containing melanoma. To improve this ratio, we added a second dataset with additional malignant cases [1], which brought the total to 37,648 skin lesion images. The data was split such that 60%, 20% and 20% was used for training, validating and testing respectively. Data Augmentation was performed on the training data to introduce small variations in the form of random rotations, horizontal and vertical flipping, resizing, brightness, and saturation shifts. This means the training data is subtly altered each time it is presented to the model. Figure 2 shows two examples of raw and augmented images respectively. Figure 2 : Example photographs in the training data. In each pair of images, the raw data is shown on the left and an augmented image example is shown on the right. Table 1 shows the test performance of all the models ((a) without and (b) with transfer learning). Eight of the ten CNN models performed significantly better with TL across all 4 metrics, and none of the models are significantly harmed by TL on any metric, demonstrating a clear benefit of transfer learning for melanoma detection. The best performing models are EfficientNet [17] and MnasNet [35] , which significantly outperform dermatologists [24] on AUROC. From the ROC curves shown in Figure 3 , we see that the EfficientNet can achieve a true positive rate of 0.95 while only conceding 0.1 to the false positive rate. Table 1 : Performance of the models averaged over 10 independent training runs. Tables (a) and (b) show the performance without and with transfer learning respectively. The error margins are 95% confidence intervals (CIs). We report the accuracy, area under the receiver operating characteristic curve (AUROC), area under the precision recall curve (AUPRC) and the F1 Score. Within each table, the results are ordered from least to best performance. In table (b), if the result is statistically better than the model without transfer learning in a one-tailed t-test (p < 0.05 * and p < 0.001 * * ), then it is indicated with stars. Results that significantly outperform general practitioners and dermatologists on AUROC (determined by a recent meta-analysis † [24] ) are indicated in green and blue respectively (p < 0.05).
Accuracy [10] 0.963±0.004 * * 0.902±0.015 * * 0.771±0.020 * * 0.861±0.015 * * DenseNet [9] 0.966±0.003 * * 0.904±0.011 * * 0.786±0.018 * * 0.870±0.011 * * Dermatologists † -0.91±0.02 --MobileNet [29] 0.969±0.002 * * 0.916±0.007 * * 0.806±0.015 * * 0.884±0.009 * * ResNeXt [37] 0.971±0.001 * * 0.918±0.006 * * 0.819±0.009 * * 0.891±0.005 * * GoogleNet [33] 0.973±0.002 * * 0.921±0.006 * * 0.831±0.013 * * 0.898±0.008 * * MnasNet [35] 0.974±0.002 * 0.928±0.005 * * 0.832±0.013 * * 0.901±0.007 * * EfficientNet [17] 0.975±0.002 * * 0.931±0.005 * * 0.840±0.010 * * 0.906±0.006 * * 
We used the integrated gradients method [32] to calculate feature attributions. This method computes the importance scores φ IG i by accumulating gradients interpolated between a baseline b input (intended to represent the absence of data, in our case this is a black image) and the current input x.
acc. local grad.
The CNN model is represented as ψ 2 . We observed that the models tend to focus primarily on the edges of the skin lesions ( Figure 4 ). This aligns with our expectation, since uneven or notched edges are common in melanoma [19] . Secondary to the edges, there is some importance to the lesion itself and surrounding skin. This is significant because melanomas can also show uneven texture or colour [19] .
We have conducted an extensive investigation of transfer learning for the task of melanoma detection from photographs. We have demonstrated the benefit of transfer learning with ImageNet pretraining [4] for melanoma detection on the ISIC 2020 dataset [27] . Furthermore, we show that the best performing neural networks are EfficientNet and MnasNet, which are capable of outperforming dermatologists when distinguishing melanoma from benign skin lesions. In particular, we note that these networks have been specifically designed for mobile devices [17, 35] . This may be important when it comes to data privacy and medical data regulations (as the classification can be performed locally on the user's personal device).
In future work, we aim to extend the binary classification task to classify other skin lesions such as benign keratosis, basal cell carcinoma, actinic keratosis, vascular lesions and dermatofibroma. Secondly, we would like to extend our interpretability study such that we can visualise the learnt features in the intermediate layers of the models. To do this we can leverage the approach of Mordvintsev et al. [20] whereby we obtain inputs designed to maximise the activation of hidden layers of the network. This will provide further insights as to why certain models outperform others in melanoma detection. Finally, we can validate the diagnostic technology in the community with an implementation study.
The automated diagnosis technology could be used to screen, triage, refer and follow-up patients in the community. It also has potential to reach patients who would not normally have access to dermatologists e.g. in remote areas or the developing world. The high AUROC of EfficientNet (high true positive rate coinciding with a low false positive rate) would make it well-suited to this purpose. Such a system could significantly reduce the cost and resources needed to screen and treat as it reduces the pool of patients needing to see the dermatologist.
VGG VGG [30] is an advancement of a previous deep neural network, AlexNet [15] . The model uses small receptive fields of 3x3 with five max-pooling layers. In our paper, we use VGG16.
GoogleNet GoogleNet [33] was developed in 2014 to solve the problem of overfitting by building an Inception Module, using filters of multiple sizes. Three filter sizes of 1x1, 3x3, and 5x5 are simultaneously used; whereby the 1x1 convolution is used to shrink the dimensions of the model. The GoogleNet architecture consists of 9 Inception Modules, with each module connected to an average pooling layer. SqueezeNet SqueezeNet [10] uses fewer parameters while preserving similar performance to AlexNet [15] . There are several architectural features worth noting: the use of 1x1 convolution filters, decreased number of input channels, and down-sampling later in the network.
DenseNet DenseNet [9] is similar to the architecture of ResNet but with "DenseBlocks". Each DenseBlock consists of a convolution layer, pooling layer, batch normalisation, and non-linear activation layer.
ResNeXt Built on the Residual Network and VGG, ResNeXt [37] uses a similar split-transformmerge strategy with an additional cardinality dimension (size of a set of transformations). The models borrows the repeating layers strategy from VGG and ResNet and according to the researchers, has better performance than ResNet [6] but with only 50% complexity.
MobileNet MobileNet [29] was developed for devices with smaller computational power such as smartphones. Unlike bigger deep learning networks such as VGG, MobileNet uses depthwise separable convolution, performing convolution on the input channels separately and then by pointwise convolution. This way low latency models can be developed, which are applicable to mobile devices.
ShuffleNet ShuffleNet [18] was also designed for mobile devices with small computational power. The model uses 1x1 convolution and channel shuffle, designed specifically for small networks. ShuffleNet has efficient computation while obtaining an accuracy similar to and thirteen times faster than AlexNet [15] .
MnasNet MnasNet [35] is another mobile network designed for efficient performance using a multi-objective neural architecture search approach that considers accuracy and latency. The network also uses a hierarchical search space, achieving speeds faster than MobileNet [29] .
EfficientNet EfficientNet [17] is a recent mobile network developed in 2018, which applies a compound coefficient for improved accuracy. Rather than scaling up the CNN model by an arbitrary amount, the authors use a grid search to find correlation in scaling based on the AutoML neural architecture search.
For the standard CNN model, values in a range were tested for dropout, batch size, kernel size, learning rate, number of layers, pool size, and number of convolution filters using random search, which is a more efficient method of hyperparameter optimisation than grid or manual search [11] . The search ranges and final values are shown in Table 2 . 
All deep learning methods were implemented in PyTorch [23] and were optimised using Adam [13] . The models were trained using Tesla P100 GPUs. Each model was trained over 10 independent training runs with early stopping [16] for a maximum of 15 epochs (the patience constant was set to 3). We used step decay in the learning rate (the decay was set to 0.4 with a learning patience of 1). 