GPL requires all source code be made available, but I am unsure how trained neural network models interact with GPL since it's unclear if these models count as source code.

To have a concrete example to discuss, consider this example:

Suppose you are working on a mobile application. Because the application contains GPL licensed code, the mobile application will be licensed under GPL too. The mobile application also uses a pretrained neural network model. (For simplicity, assume you used MIT licensed code that is not used in the mobile application to generate the neural network model.)

Does this pretrained neural network model count as source code? If so, does the model have to be licensed under GPL?

Question re-asked here: https://opensource.stackexchange.com/questions/6961/how-does-gpl-apply-to-neural-network-models

  • IMO, training dataset is required to reproduce and modify models. As main idea of GPL is openness for modification, training dataset would be a necessary part of source code.
    – Basilevs
    Jun 14, 2018 at 3:13
  • 1
    Why the downvotes? I think this is an interesting question. Maybe ask on law SE
    – marstato
    Jun 14, 2018 at 6:17
  • 4
    There are a few interesting questions here before the GPL starts being relevant: (1) Is the NN model code to be run, or data to be processed by the program? I'd tend towards the latter. (2) Is a NN model a creative work? If not, it cannot be copyrighted. I'd argue that NN models are not creative works as they are derived from training data by a mathematical procedure. Similarly, the histogram distribution of a dataset would not be copyrightable. However, related rights like database rights might be relevant, as the model could be interpreted as a reduced representation of the training data.
    – amon
    Jun 14, 2018 at 8:10

1 Answer 1


The GPL is quite clear that its concern is with the distribution of the sources of a system in the preferred form of the work for making changes in it. Nobody develops a neural network by editing its weights one by one. What must be redistributed in this case is the code that allows automatic adjustment of the weights based on training data, not the resulting weights.

  • 1
    By this logic, then you'd also need to open up the training set as well, as without the training set, the trainer code is useless for the purpose of modifying a neural network.
    – Lie Ryan
    Jun 14, 2018 at 8:39
  • 3
    I disagree. Very often you can write a data-handling program without having any samples of the data beforehand. I know I have written feature vectorizers long before the training data became available. Jun 14, 2018 at 8:54
  • 1
    Interestingly, the top voted answer on opensource says quite the opposite. And I can follow the logic of both answers - hard to tell which one is "right" , if there is right and a wrong position here. Maybe it is case dependent?
    – Doc Brown
    Jun 16, 2018 at 8:08
  • @LieRyan Ah, but the trained neural network is GPLed here and the question is how to provide the source code for this network? Not just the source code for other networks of this type. The source code for this network is the exact training code and training data which produced it. If you feed it different training data you'll get a different network.
    – user253751
    Jul 9, 2021 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.