# Saving trained neural nets in csv or txt format

**URL:** <https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397>\
**Category:** Uncategorized\
**Created:** [April 8, 2020, 4:34pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397 "2020-04-08T16:34:02Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![anassallabou](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/anassallabou/32/144_2.png) [@anassallabou](https://community.konduit.ai/u/anassallabou)\
**Post date:** [April 8, 2020, 4:34pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/1 "2020-04-08T16:34:02Z")

</div>

hello guys,  
i wanna save my trained neural ntes in csv or txt format and i don’t know how,  
can someone help me please  
and thank you

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 8, 2020, 4:51pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/2 "2020-04-08T16:51:07Z")

</div>

What exactly do you mean? Do you want to save your weights as a CSV?

A model saved by DL4J is a zip file. It contains the configuration of the model as well as the weights and anything else you’ve decided to save there like normalizer stats.

Saving all this in a single text based file doesn’t make sense.

If you just want to save the weights this way, you can get them from the model with [model.params()](https://deeplearning4j.org/api/latest/org/deeplearning4j/nn/api/Model.html#params--) and write them with [Nd4j.writeTxt](https://deeplearning4j.org/api/latest/org/nd4j/linalg/factory/Nd4j.html#writeTxt-org.nd4j.linalg.api.ndarray.INDArray-java.lang.String-).

---

<div class="post-metadata">

**Author:** ![anassallabou](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/anassallabou/32/144_2.png) [@anassallabou](https://community.konduit.ai/u/anassallabou)\
**Post date:** [April 10, 2020, 10:06pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/3 "2020-04-10T22:06:04Z")

</div>

thank you so much for your help,  
and i wanna know if there is any link that can help with SVM in DL4J,  
and thank you

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 11, 2020, 2:45pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/4 "2020-04-11T14:45:51Z")

</div>

DL4J doesn’t implement any SVM algorithms, what exactly are you trying to do?

---

<div class="post-metadata">

**Author:** ![anassallabou](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/anassallabou/32/144_2.png) [@anassallabou](https://community.konduit.ai/u/anassallabou)\
**Post date:** [April 11, 2020, 7:02pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/5 "2020-04-11T19:02:23Z")

</div>

i am trying to build an ai system for fabric defaults detection

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 13, 2020, 8:33am UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/6 "2020-04-13T08:33:32Z")

</div>

I meant what you are trying to do with DL4J and SVM’s. How you imaginge that working together.

---

<div class="post-metadata">

**Author:** ![anassallabou](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/anassallabou/32/144_2.png) [@anassallabou](https://community.konduit.ai/u/anassallabou)\
**Post date:** [April 13, 2020, 3:02pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/7 "2020-04-13T15:02:34Z")

</div>

i have my neural nets trained, but i wanna have more accurate decision, so i thought if i could add a classification method like SVM or KNN, that will give us an accurate decision

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 13, 2020, 3:15pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/8 "2020-04-13T15:15:01Z")

</div>

In that case, you can try using your neural network as a feature extractor, and get the layer before the output layer and feed that into an SVM.

---

<div class="post-metadata">

**Author:** ![anassallabou](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/anassallabou/32/144_2.png) [@anassallabou](https://community.konduit.ai/u/anassallabou)\
**Post date:** [April 13, 2020, 3:27pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/9 "2020-04-13T15:27:09Z")

</div>

thank you so much, but if you have an exemple to get an idea that will be great

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 13, 2020, 3:34pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/10 "2020-04-13T15:34:11Z")

</div>

Sorry, I don’t have an example that shows exactly that use.

There is a small example of using the [DL4J transfer learning API for feature extraction](https://deeplearning4j.konduit.ai/tuning-and-training/transfer-learning#iv-saving-featurized-datasets-and-training-with-them) in the documentation. So you can start from there.  
Once you transformed your input data that way, you can try using that transformed data as an input to your SVM. How exactly that will look like will depend on the library that you’ve chosen for it.

---

<div class="post-metadata">

**Author:** ![anassallabou](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/anassallabou/32/144_2.png) [@anassallabou](https://community.konduit.ai/u/anassallabou)\
**Post date:** [April 13, 2020, 3:41pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/11 "2020-04-13T15:41:36Z")

</div>

thank you so so much for your help i am really grateful, but what do you mean " will depend on the library that you’ve chosen for it "

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 13, 2020, 8:04pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/12 "2020-04-13T20:04:34Z")

</div>

It means that I can’t really help you with any thing that goes beyond what we support with DL4J directly.

---

<div class="post-metadata">

**Author:** ![anassallabou](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/anassallabou/32/144_2.png) [@anassallabou](https://community.konduit.ai/u/anassallabou)\
**Post date:** [April 13, 2020, 10:03pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/13 "2020-04-13T22:03:12Z")

</div>

so i have to forget about this method and what about KNN

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 14, 2020, 7:30am UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/14 "2020-04-14T07:30:42Z")

</div>

It would be essentially the same setup: You use your NN as a feature extractor and then in a separate step you feed that data to a KNN.

However, I really doubt that you will actually get better performance that way. KNN is only really useful if you’ve got lots of unlabeled data, but you know that it is going to cluster in K clusters.

SVMs are linear classifiers, so using them with an NN as a feature extractor is pretty close to what you’d get by essentially using the NN as the kernel method for your SVM.

---

<div class="post-metadata">

**Author:** ![anassallabou](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/anassallabou/32/144_2.png) [@anassallabou](https://community.konduit.ai/u/anassallabou)\
**Post date:** [April 14, 2020, 3:12pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/15 "2020-04-14T15:12:42Z")

</div>

Thank you so much for your help i am so grateful

---

<div class="post-metadata">

**Author:** ![anassallabou](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/anassallabou/32/144_2.png) [@anassallabou](https://community.konduit.ai/u/anassallabou)\
**Post date:** [April 14, 2020, 3:39pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/16 "2020-04-14T15:39:32Z")

</div>

but does DL4J implement any other classification method

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [April 14, 2020, 3:41pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/17 "2020-04-14T15:41:51Z")

</div>

Deeplearning4J implements only neural networks for classification.

---

<div class="post-metadata">

**Author:** ![anassallabou](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/anassallabou/32/144_2.png) [@anassallabou](https://community.konduit.ai/u/anassallabou)\
**Post date:** [April 14, 2020, 5:24pm UTC](https://community.konduit.ai/t/saving-trained-neural-nets-in-csv-or-txt-format/397/18 "2020-04-14T17:24:59Z")

</div>

Thank you so much for all your help
