Skip to content

Commit

Permalink
fix(api): levelup save and display to top-level
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxiao committed Oct 26, 2021
1 parent 320ec5d commit 539923b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Perfect! Now `embed_model` and `labeled_data` are given by you already, simply d
```python
import finetuner

finetuner.fit(
tuned_model, _ = finetuner.fit(
embed_model,
train_data=labeled_data
)
Expand All @@ -96,7 +96,7 @@ You can use Finetuner to interactive label data and train `embed_model` as below
```python
import finetuner

finetuner.fit(
tuned_model, _ = finetuner.fit(
embed_model,
train_data=unlabeled_data,
interactive=True
Expand All @@ -111,7 +111,7 @@ worries, Finetuner can convert your model into an embedding model and train it v
```python
import finetuner

finetuner.fit(
tuned_model, _ = finetuner.fit(
general_model,
train_data=labeled_data,
to_embedding_model=True,
Expand All @@ -127,7 +127,7 @@ worries, Finetuner can help you train an embedding model with interactive labeli
```python
import finetuner

finetuner.fit(
tuned_model, _ = finetuner.fit(
general_model,
train_data=unlabeled_data,
interactive=True,
Expand Down
24 changes: 24 additions & 0 deletions docs/basics/fit.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,28 @@
```{include} ../index.md
:start-after: <!-- start fit-method -->
:end-before: <!-- end fit-method -->
```

## Save model

```python
import finetuner

finetuner.save(model, './saved-model')
```

```{caution}
Depending on your framework, `save` can behave differently. Tensorflow/Keras saves model architecture with the parameters, whereas PyTorch & Paddle only saves the trained parameters.
```

## Display a model

```python
import finetuner

finetuner.display(model)
```

```{caution}
Depending on your framework, `display` may require different argument for rendering the model correctly. In PyTorch & Paddle, you will also need to give the `input_size` and sometimes `input_dtype` to correctly render the model.
```
2 changes: 1 addition & 1 deletion docs/components/tailor.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ In general, you do not need to call `to_embedding_model` manually. You can use i

## `display` method

Tailor also provides a helper function `finetuner.tailor.display()` that gives a table summary of a Keras/PyTorch/Paddle model.
Tailor also provides a helper function `finetuner.display()` that gives a table summary of a Keras/PyTorch/Paddle model.

Let's see how to use them in action.

Expand Down
2 changes: 1 addition & 1 deletion docs/components/tuner.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Although siamese and triplet loss works on pair and triplet inputs respectively,

## `save` method

After a model is tuned, you can save it by calling `finetuner.tuner.save(model, save_path)`.
After a model is tuned, you can save it by calling `finetuner.save(model, save_path)`.


## Examples
Expand Down
8 changes: 4 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Perfect! Now `embed_model` and `train_data` are already provided by you, simply
```python
import finetuner

finetuner.fit(
tuned_model, _ = finetuner.fit(
embed_model,
train_data=train_data
)
Expand All @@ -159,7 +159,7 @@ emphasize-lines: 6
---
import finetuner
finetuner.fit(
tuned_model, _ = finetuner.fit(
embed_model,
train_data=unlabeled_data,
interactive=True
Expand All @@ -183,7 +183,7 @@ emphasize-lines: 6, 7
---
import finetuner
finetuner.fit(
tuned_model, _ = finetuner.fit(
general_model,
train_data=labeled_data,
to_embedding_model=True,
Expand All @@ -208,7 +208,7 @@ emphasize-lines: 6, 7
---
import finetuner
finetuner.fit(
tuned_model, _ = finetuner.fit(
general_model,
train_data=labeled_data,
interactive=True,
Expand Down
5 changes: 5 additions & 0 deletions finetuner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,8 @@ def fit(
from .tuner import fit

return model, fit(model, train_data, *args, **kwargs)


# level them up to the top-level
from .tuner import save
from .tailor import display

0 comments on commit 539923b

Please sign in to comment.