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 and a set of copyrighted images to generate and train the neural network model.)

In short:

At development time: Neural network training code and training data make a neural network model.

The final product: Mobile application code and the neural network model are in the final release binary. The training code and training data are NOT included.

  1. Does this neural network model have to be licensed under GPL?
  2. Does the code used to train the neural network model have to be made available? If so, does it have to be licensed under GPL?
  3. Does the training data used to train the neural network model have to be made available? If so, does it have to be licensed under GPL?

One could make the argument GPL dictates the distribution of the sources of a system be in the preferred form of the work for making changes in it. Nearly all neural networks are created by the use of training code and a training set of data. Because nobody develops a neural network model by editing its weights one by one, what should be redistributed in this case is the code that allows automatic adjustment of the weights based on training data, not the resulting weights.

However, one could argue since the model itself can be parsed and loaded using only a few lines of code (with the appropriate machine learning library) the model itself is already in the preferred form. The training code is useful for creating a model from scratch but is not necessary for modifying the model.

[Question reposted from https://softwareengineering.stackexchange.com/questions/372548/for-gpl-do-trained-neural-network-models-count-as-source-code?noredirect=1#comment818262_372548 since it was marked off-topic]

  • 7
    Whether or not this is allowed on SoftwareEngineering.SE, it is certainly on-topic here. Welcome to OpenSource.SE, and thanks for the interesting first question!
    – apsillers
    Jun 14, 2018 at 16:10

4 Answers 4


Two critical questions are:

  1. Are neural network models code? Importantly, are they code that directly combines with the GPL-licensed code under copyright? It is instead possible that they are data. If they are data, it is unlikely that they form a combined work with the GPL-licensed code that process them. There is a related GPL FAQ item about GPL code processing non-GPL data:

If a programming language interpreter is released under the GPL, does that mean programs written to be interpreted by it must be under GPL-compatible licenses?

When the interpreter just interprets a language, the answer is no. The interpreted program, to the interpreter, is just data; a free software license like the GPL, based on copyright law, cannot limit what data you use the interpreter on. You can run it on any data (interpreted program), any way you like, and there are no requirements about licensing that data to anyone.

  1. Are neural network models even copyrightable? If neural networks are created in such a way that it does not require a "modicum of creativity" from a human (in the United States -- other jurisdictions likely have similar rules) to create any particular neural network, they are not copyrightable. In general, the choice of mathematical parameters (or selection of input training sources) for a mathematical, automated process does not satisfy this criterion for copyrightability. If neural networks are not copyrightable, I would not expect that they form a combined work with the program under copyright. (Note they a neural network model could still be covered by sui generis database rights in some jurisdictions, without changing the impact of this consideration.)

    Caveat: it is reasonable to guess that certain kinds of models, built with copyrightable input data (like human-authored documents, articles, stories, etc.) might, under certain conditions, retain the copyright status of their input training data, if they do not fully abstract away copyrightable expression from non-copyrightable mechanical patterns. (However, this standard has yet to be tested in a court.) However, this question asks about whether the licensing status of the software that uses the trained model could impose requirements on the model, not whether a model can have its copyright status influenced by its original training data.

If the answer to either of these is negative, then the GPL requirements do not apply.

  • 1
    Neural network models certainly seem like data. Tensorflow saves models as protocol buffers: "Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler." (developers.google.com/protocol-buffers/?hl=en) But programming language interpreters are very different from mobile applications since the mobile application is meant read a specific neural network model (and maybe future updated versions of the model).
    – emettomet
    Jun 14, 2018 at 19:25
  • 2
    I am 99% certain neural network models are NOT copyrightable. If neural network models were copyrightable, then someone would have copyrighted one. But a search of "neural networks" on the US Copyright Office website turns up research papers, books, and images about neural networks but no neural network models.
    – emettomet
    Jun 15, 2018 at 0:01
  • 1
    If I understand the OP correctly, the model seems to be an essential part of the system, not just arbitrarily exchangeable like an interpreted program for an interpreter. So are you really sure it is "unlikely that they form a combined work"?
    – Doc Brown
    Jun 15, 2018 at 22:50
  • 1
    @DocBrown I agree it's counterintuitive, and maybe I'm wrong (I framed my answer as questions instead of statements, after all!). My argument goes something like this: consider an AGPL web app that uses a config file with server-specific secret keys. Insofar as those keys are just data, they don't need to be made available to users as part of the corresponding source (but the config file in general does, with meaningful if different values). I'm arguing that a NN model is a massively scaled-up version of that, but which has the same copyright consequences. Again, I might be wrong.
    – apsillers
    Jun 16, 2018 at 1:13
  • 1
    @user253751 Can't you supply a model trained on other data or by a different algorithm? I appreciate that different keys produces results that are semantically much closer to one another than different models, so the observed behavior of the work might be quite different for different models. But as far as copyright considers the written work of the computer program, the model appears (in my view) to be input data in much the same way as a key. (Or can you really not produce a model that will operate, even differently, in the same execution context without the original? I am not an ML expert.)
    – apsillers
    Jul 12, 2021 at 14:06

So you have an application that uses GPL code, even if part of the project can be separated and used under different terms (MIT), the project as a whole needs to comply with the GPL.

Note that the overall project design can also impact on what you can do. If the neural network is a library that links with the main program it can fall into GPL but if it is a separate program that supplies data to the main program it would not.

While data output from a GPL program is not covered by the GPL terms, Section 1 of the GPL states -

The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities.

So if your training data files are stored or converted to C/C++ code that gets compiled into the final app, then the training data will fall into the GPL.

Even if the data is stored as separate files that are only read at runtime, you may need to supply at least a basic subset of data that allows the user to "compile, install and run" the project you are sharing, while your paid application gets bundled with more useful data files. Offering your advanced data set as an optional download available once the app is installed could be another way to separate it from the open project.

Note that you are under no obligation to make the open version of the program run "really well" or to any extent of usefulness on its own, consider that the linux kernel has a very limited use without other supporting projects to make a complete system distribution. You also don't have to make the project publicly available, you only have to make the code available to users of your binary program.

  • 1
    I should have been more clear the neural network model is made during development and is not made at runtime. No training code or training data is included in the released binary. Only the mobile application code and the neural network model (which is data and not code) is.
    – emettomet
    Jun 15, 2018 at 14:42

I Am Not A Lawyer, but I don't see why this would be any different from "normal" executable code. You need to distribute the source code for your app. Both GPLv2 and GPLv3 are clear on the definition of "source code":

The source code for a work means the preferred form of the work for making modifications to it.

So, do you prefer to modify the neural network by starting from the neural network blob, or would you train a new one?

I can see that it could be faster to update a neural network by starting from an existing network and doing more training. You can add new code to an executable file, too, but that doesn't mean it's the preferred form of the work for making modifications to it - it's better to have the original source code. If you can re-train the neural network from scratch, you can make more kinds of modifications, like changing the number of layers. For this reason I think you should consider the training code and data as "source code" of the neural network.

@apsillers has said that the neural network might not be copyrightable in the first place, since it's the output of a mechanical process. However, I don't think that's relevant.

Recall why your program has to be GPL to begin with. Because you are using GPLed code you must comply with the license of that code. The license of that code says that if you make a derivative work of that code - and your whole app is a derivative work - you must only distribute it under the terms of the GPL. If you distribute your app under the terms of the GPL, that means you must distribute the source code for the entire app, including the neural network part. The whole app is certainly a copyrightable work, even if particular parts of it might not be copyrightable by themselves.

Besides, if it wasn't copyrightable by virtue of being the output , that would just mean it wasn't copyrightable by you. If you use a computer to ("mechanically") convert a .mp3 file to .wav, the copyright holder of the .mp3 file also owns the copyright to the .wav. It's not held by you, and it's not held by nobody. If this argument is valid, it would mean the neural network's copyright would be held by whoever held the the training data's copyright - assuming that the training data was in fact copyrightable.

@apsillers has also questioned whether a neural network model counts as code. I don't think that's relevant, either. The GPL applies to the entire app, not just the part that is labelled "code".

Besides, the GPLv2 gives you permission to distribute your work in source code form, or in "object code or executable form". The latter is a bit ambiguous, but it could be interpreted to mean that "object code form" and "executable form" are the same thing. In that case, you wouldn't have permission to distribute derivative works in non-code forms at all!

GPLv3 is clearer:

“Object code” means any non-source form of a work.

so your network has to either count as "object code" or "source code" in the GPLv3 - no ifs or buts.

  • 1
    This applies only if the model is copyrightable; if it's not, the GPL simply does not apply to it as it derives it power solely from copyright law. Can you provide some evidence that models are copyrightable? Jul 12, 2021 at 20:54
  • 1
    You say "The GPL applies to the entire app" but the full question I ask directly relates to what constitutes the "entire app" under copyright law: "are they code that directly combines with the GPL-licensed code under copyright?" If the answer is "no", then they are excluded from the scope of the GPL'd copyrighted work, and therefore not within the material under the GPL's copyleft obligations. (The GPL can only impose copyleft obligations to material within the same work under copyright law.) The answer may be "yes" but this answer currently doesn't present any argument toward that end.
    – apsillers
    Jul 13, 2021 at 2:51
  • @apsillers What does the user get when they click the "download" button? That's the app Jul 13, 2021 at 8:14
  • 1
    @user253751, "the app" can still be multiple works under copyright law, even if you download it as one package. For example, if your app consists of code and some images, then the thing you download will be a compilation of the code and the images (a mere aggregation) and each of them can have a different license that could even be incompatible with the other licenses. It is not like that the images need to be under the GPL just because the code is. Jul 13, 2021 at 9:18
  • 1
    @user253751 The closest case law I know of is rather distant, about the limits of ShareAike across pages of an atlas (Drauglis v Kappa), but it is the opinion of the FSF that certain software arrangements can be coresident but legally distinct under copyright, including when one part is input for another part: (1) gnu.org/licenses/gpl-faq.en.html#MereAggregation (2) gnu.org/licenses/gpl-faq.en.html#GPLPlugins (3) gnu.org/licenses/gpl-faq.en.html#InterpreterIncompat
    – apsillers
    Jul 13, 2021 at 11:37

Everybody here seems to forget that inside a saved model, besides the weights, there is a graph and a graph is a program.

Actually, you can think of it as a compiled version of a fragment of the original GPL program and so, IMO, the GPL sticks to it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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