I am writing software that makes use of a neural net. What makes my network special as compared to others, is the way I train them. Its non standard, its something that I don't want to give away to another company. So I've been thinking about how to protect myself against miss-use / stealing of my neural net training code. The company who is buying this software has about 12 C++ coders hired, while I write solely in C#, and I have doubt that I could keep some parts secret to them, as reverse engineering is likely to occur. When the software i make becomes a success.

So at first I though lets put some secure key in as a requirement to create an instance of this class, and without that drop execution, some sort of licence construction. That sounds nice, but as for neural networks training them is an essential part; training methods should be able to create neural networks. Then a trainer would need a key generator as well...

Then I was thinking how about leaving-out the option to train data. So the other company is only able to load the trained brain. But not to train the neural network, by placing all training related code into a separate .cs file as a partial class. Then I simply develop the neural net class as a whole on my private github. But take out only the snippet without training routines to use in my customer program.
I wonder if this would be a wise thing to do, or if it would result in some anti pattern. ???

one anti pattern for example is maintaining the neural net code.
To "copy" one file of a github project to another project isnt ideal.

This is not a general duplicate of another protections question. This is about a program requiring A+B parts to train, but only A to run it, and not providing the B part.

  • 6
    If you want to protectet your training algorithm get a patent for it. Then make sure the license forbids reverse engineering and usage of the code outside of the software that you provided it with. There's nothing more you can do.
    – marstato
    Jun 19, 2017 at 13:28
  • 8
    You could also do the training online on one of your servers. Users upload training data and download the trained network. Training code stays on the server and under your control.
    – marstato
    Jun 19, 2017 at 13:36
  • 1
    Thats not a bad idea, must think about it, since so far its not a web application.
    – Peter
    Jun 19, 2017 at 13:38
  • 3
    If you want to keep something secret, do not give it to anyone. If you do, all bets are off, especially in a case when the use of your secret does not leave any obvious, hard-to-remove trail, so even a litigation (expensive as it is) can't be your tool. Do not sell, lend, etc your secret tool; instead, let people pay you for you applying it to their data.
    – 9000
    Jun 19, 2017 at 14:58
  • 3
    Have a tip from someone who plays for a long time with neural nets (both for commercial and hobbyist purposes) - You seem to be starting of on the business of artificial intelligences. If your work is really novel, write a paper and publish it on your field. Publish it. Make everyone knows that you are the creator of this thing. You can earn way more money polishing your toolset and adding new clients to your profile than hiding away tools that will be outdated anyway in a few months. Don't waste time protecting already done code - waste time creating new, better code. DRM is always bad.
    – T. Sar
    Jun 19, 2017 at 18:16

3 Answers 3


Create two assemblies. Assembly A contains all of the classes required to use the trained model, but none of the code which trains the model. Assembly B contains only the classes which train models, and nothing else. Assembly B references assembly A.

Deliver assembly A, and keep assembly B to yourself.

Your question and comments makes it sound like you have one "neural net class" which contains the code both for using and training the model. Don't do that. It also sounds like you're thinking of having two versions of the neural net code, one with training functionality and one without training functionality. Don't do that either.

Instead, have a Model class (in assembly A) which contains the code necessary for using the model, but none of the code which is essential to training the model; and have a separate Trainer class (in assembly B) which trains the model by interacting with Model objects. Assembly B should not contain any of the functionality of the Model class.

  • The buyer is probably buying the training scheme, not the trained data. Buying trained data is rarely useful if you ever need to change the specs of your software - and, with a 12-person team, chances are they probably will.
    – T. Sar
    Jun 19, 2017 at 18:31
  • no eventually its their customer who should deliver the train data so that I with B can make it optimal; without neural net the software works but not that good, its mainly used to optimize a solution.
    – Peter
    Jun 19, 2017 at 19:03
  • As said, any software on a machine controlled by someone else will end telling everything under torture (i.e. reverse engineering). It's only a matter of time, cost and benefit.
    – Christophe
    Jun 19, 2017 at 21:26

When a company is buying your software, you will have a contract that states what you deliver and what they can do.

Chances are that what you are planning will cause them to not sign a contract in the first place. They don't get what they want, and they have to work with someone who might come up with other interesting ideas in the future. I would run.

Remember, there's a contract. A company can't just steal things. Most companies don't. And those that do usually get their arse sued off.

  • I've seen terrible examples in the past, where Big companies just let other companies go bankrupt so they can take over their business, if they cannot win by playing fair, there is often lot of legal options to act very nasty towards others. Good contract could help but can be hard to agree upon. Contracts can be a battle a topic I rather leave outside of this topic
    – Peter
    Jun 19, 2017 at 19:07

Software is a kind of knowledge, and knowledge is extremely difficult to protect.

Can you protect your software with technical means ?

You can't do anything in your code about theft, if it is self-sufficient. Even without the source code, any protection mechanism that you could have implemented, would need some functionality in your code to be managed. Reverse engineering could then find out the details, even decryption key.

The only active technical protection that you could consider would be to make your software dependent on some web service under your control (e.g. training the net as a service), or a physical device that contains a part of your code in an encrypted area (e.g. the "dongle" approach). However both require an extra effort on your side, and might not be accepted by your customer.

Can you legally protect your software ?

On the legal side you may consider to apply for a patent if your invention is brand new and if you're living or making business in one of the rare country that allows software patent. But be aware that huge research efforts are made on machine learning and neural nets, and it is not to be excluded that your invention was already invented by some lab around the world, without you knowing from it.

Another approach is to rely on a restrictive licence agreement to legally forbid the company to misuse your code for another purpose. This should be combined with a non-disclosure agreement that shall enforce legal protection also agains theft of your customer's employee who might walk away with the knowledge. The principle is that the company signs an NDA with you (and this might be independent of the final contract and the financial details), and then commits to organise NDA with anyone who has access to the code.

Legal protection is a theoretical protection, because it'll be up to you to find out any infringement and demonstrate that it'll be a theft, and pay for all the legal expertise, unless you win a trial and get reimbursed. But a serious business partner may have much more incentive in having a good relationship with you and respect the terms of the contract if you add value to his products.

In any case, and especially if it's about big business, for the legal aspects, you'd better consult a qualified legal expert or lawyer in your jurisdiction, rather than relying on personal opinions on some internet forums. (By the way, I'm not a lawyer and this is not a qualified legal advice)

Further reading

  • The software IP detective handbook from Bob Zeidman gives a great introduction on Intellectual Property and related concepts for non-lawyers and software engineers.
  • 1
    This is a very good answer. Never assume your thing is super brand new in machine learning - there is a very real chance that someone, somewhere, had exactly the same idea already implemented and published on a paper. This field is that dynamic.
    – T. Sar
    Jun 19, 2017 at 18:34
  • Indeed ! I know some people working on machine learning with neural nets and genetic algorithms since the early 90's in large public research labs. I'm always impressed to hear about their latest findings. And they are only a few of the many many others around the world who explore this field. On the other hand, I invented myself a pattern matching algorithm inspired by a general article, in a country without SW-patent, only to discover 20 years later that someone applied for a US patent on the other side of the globe, based on the same article, and after my invention...
    – Christophe
    Jun 19, 2017 at 18:49
  • Well its still an area with lots of grays and where some ideas are new. Did you know the first one's where invented in 1943, but then for example back propagation or evolutionary strategies didn't exist, and so it was less usefully then. Some machines kept calculating, but people had no idea of what they where calculating. These days i think its more about finding use for, and combining with other math combinations, and sometimes people invent some improvements.
    – Peter
    Jun 19, 2017 at 18:59
  • oh and i dont have the means financially to start a court battle.
    – Peter
    Jun 19, 2017 at 19:16
  • @user3800527 Fascinating ! I was not aware that it was so old. But now that you mention it, I've seen in Robert Wieners pioneering work on cybernetics published in 1948 a chapter on "computing machines ans the nervous system" and "Brainwaves and self-organizing systems".
    – Christophe
    Jun 19, 2017 at 21:09

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