Transfer learning is supposed to save training time. In my experiment, it took 5.7 times longer and gained nothing.
The setup
No pre-trained model exists for this kind of security data, so I built one. I split NSL-KDD network traffic by protocol. An LSTM learned from about 14,000 sequences of TCP connections. Then I adapted it to UDP and ICMP traffic using only 1,200 labeled sequences.
The adaptation ran in two phases. First, I froze the pre-trained layers and trained only a new output layer. Then I unfroze everything and continued at a learning rate ten times lower.
For a fair comparison, I trained an identical model from scratch on the same 1,200 sequences.
The result
Accuracy was effectively tied: 0.9508 for transfer, 0.9465 from scratch. That gap is three sequences out of 691. Rerunning the scratch model with different random seeds moved it by the same three.
The difference was cost. The scratch model finished in 25 epochs and 4.4 seconds. The transfer model needed 183 epochs and 24.9 seconds.
Why it didn’t pay off
The two domains only looked similar. They shared the same columns, but only two of the ten target services appeared in the source data. The connection flag field had eleven values in TCP traffic and one in UDP/ICMP.
The pre-trained model had learned TCP session structure. Fine-tuning had to largely overwrite that before it became useful. The target task was also easy, which left little room for prior knowledge to help.
The takeaway
Transfer learning works when the domains are close. Measuring that distance first would have predicted this result.
The full report is on my CYSE 420 course page.
CYSE420_Assignment07_Report