Performance drawback of tf.numpy_function? - numpy

I'm using a tf.numpy_function to load a file in my tensorflow program.
I can't find sufficient information about the drawbacks of using numpy_function, would there be enough that it's worth the trouble of passing this function to tensorflow compatible code ?
Thanks a lot

Related

is it possible to protect tensorflow training code

Now a days very high power shared GPUs are available for deep learning training at very cheap price. But protecting your training dataset and code is problem there because GPU owner can see your files. I know that it is impossible to completely prevent, reverse engineering of the code and data, but I want to make it very very hard. I am thinking to encrypt my datasets images and decrypt problematically before feeding to the model.But the problem is, anyone intelligent enough can see my decrypted data when i feed to the model.
What are the options to hide TensorFlow code and build c++ binary? I tried Nuitka, its not working with tensorflow. I searched that Cython will also not work. There is tf-encrypted but, it seems like that work with older version of tensorflow (1.x). Please suggest some clever way which works.

Convert torch model (torch.save) into matricial formulas that can be handled with basic Python

Please could you tell me if it is feasible to transform a torch model (torch.save) into algebraic matrices/ equations that can be operated with numpy or basic Python, without the need to install torch and other related libraries (that occupy a lot of space)? In an afirmative case, could you please give me some hints or a link with explanations? Thank you very much.
I'm not aware of any way to do this without a lot of your own work. Basically you'd have to port most of the pytorch library to numpy, which would be a huge project. If space is an issue check if you can save some space by e.g using earlier torch versions or using only the CPU-versions of pytorch.

Tensorflow Federated in C++

I'm trying to find a way to utilise Tensorflow Federated in C++. I know it's possible to do it for the regular Tensorflow with the Core API, however I can't find a way for Federated. If it's not possible suggestions for workarounds would be highly appreciated!
It would be helpful to know which part(s) of TFF you want to use in C++, and what your use case is, as that will influence the answer:
The APIs for defining federated computations (tff.federated_computation); as with TensorFlow, these are pretty tightly coupled to Python.
Executing serialized computations (stored as instances of computation.proto). This can conceptually be done using a purely C++ API, though TFF doesn't currently provide such a runtime.
TFF has since implemented a C++ runtime along the lines of Brendan's answer. TFF's CC directory contains the code; most of the implementation is in the executors directory.
These APIs can certainly be called from C++ code; see, e.g., the implementation of TFF's RunWorker, which starts and runs a server that can execute TFF computations.

regarding caffe to tensorflow

Currently, there are a lot of deep learning models developed in Caffe instead of tensorflow. If I want to re-write these models in tensorflow, how to start? I am not familiar with Caffe structure. It seems to me that there are some files storing the model architecture only. My guess is that I only need to understand and transfer those architecture design into Tensorflow. The input/output/training will be re-written anyway. Is this thought meaningful?
I see some Caffe implementation also need to hack into the original Caffe framework down to the C++ level, and make some modifications. I am not sure under what kind of scenario the Caffe model developer need to go that deep? If I just want to re-implement their models in Tensorflow, do I need to go to check their C++ modifications, which are sometimes not documented at all.
I know there are some Caffe-Tensorflow transformation tool. But there are always some constraints, and I think re-write the model directly maybe more straightforward.
Any thougts, suggestions, and link to tutorials are highly appreciated.
I have already asked a similar question.
To synthetise the possible answers :
You can either use pre-existing tools like etheron's kaffe(which is really simple to use). But its simplicity comes at a cost: it is not easy to debug.
As #Yaroslav Bulatov answered start from scratch and try to make each layer match. In this regard I would advise you to look at ry's github which is a remarkable example where you basically have small helper functions which indicate how to reshape the weights appropriately from caffe to Tensorflow, which is the only real thing you have to do to make simple models match and also provides activations check layer by layer.

How to deploy parsey's cousins with tensorflow serving

Are there instructions or some documentation somewhere or could somebody describe how to deploy the models available as "Parsey's Cousins" (see https://github.com/tensorflow/models/blob/master/syntaxnet/universal.md) with SyntaxNet under Tensorflow Serving? Even deploying just Parsey is a rather complex undertaking that is not really documented anywhere, but how to do this for the additional 40 languages?
This pull request partially addresses your request, but it still has some issues: https://github.com/tensorflow/models/pull/250.
We do have some tentative plans to provide easier integration between SyntaxNet and Tensorflow Serving, but no precise timeline.
Just for the benefit of anyone else who finds this question, after some digging around on GitHub, one can find the following issue started by Johann Petrak:
https://github.com/dsindex/syntaxnet/issues/7
a model from parsey's cousin is not able to export by that patch due to version mismatch
So whilst some people have been able to modify syntaxnet so that it works with Tensorflow Serving, this seems to be at the cost of using a version which is not compatible with Parsey's Cousins.
Currently the only way to get Tensorflow Serving working with languages other than English is to use something like dsindex's code and train your own models.