You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If your run has generated a Tensorflow model, you can declare it as such. This will load the model into the Model Library on the Dotscience Hub, and will enable automated deployment and model tracking features.
335
+
336
+
This can be done with`model()`or`add_model()`:
337
+
338
+
```python
339
+
import dotscience as ds
340
+
import tensorflow as tf
341
+
342
+
ds.script()
343
+
ds.start()
344
+
345
+
...
346
+
347
+
tf.saved_model.simple_save(
348
+
tf.keras.backend.get_session(),
349
+
ds.model(tf, "potatoes", "./model"), # <---
350
+
inputs={'input_image_bytes': model.input},
351
+
outputs={t.name:t for t in model.outputs})
352
+
353
+
...or...
354
+
355
+
tf.saved_model.simple_save(
356
+
tf.keras.backend.get_session(),
357
+
"./model",
358
+
inputs={'input_image_bytes': model.input},
359
+
outputs={t.name:t for t in model.outputs})
360
+
361
+
ds.add_model(tf, "potatoes", "./model") # <---
362
+
363
+
ds.publish('Trained the potato classifier')
364
+
```
365
+
366
+
The first argument to `model`or`add_model` should be the Tensorflow module itself, as imported by `import tensorflow as tf`in our example. This is used to identify it as a Tensorflow model (other types of model will be used in future), and to record the Tensorflow version used to generate it.
367
+
368
+
The second argument is the model name for the Model Library. In this case, we called it `potatoes`, as our model is a potato classifier.
369
+
370
+
The third argument is the path to the directory we're saving the Tensorflow model in, in this case `./model`. If called as `model()` rather than `add_model()`, this path is returned, so that it can be used to wrap the output path argument to `simple_save` in our example.
371
+
372
+
For classifier models, an optional keyword argument is supported in both `model()`and`add_model()`: `classes` can be provided as a path to a CSVfile listing your classes, to enable automatic model metric tracking in deployment.
373
+
374
+
Note that we don't need to call `output()` for the paths passed to `model()` and `add_model()`; they automatically declare the files as outputs from this run.
375
+
332
376
## Multiple runs
333
377
334
378
There's nothing to stop you from doing more than one "run" in one go; just call `start()` at the beginning and `publish()` at the end of each.
0 commit comments