# TensorFlow

## TensorFlow

References:

<https://www.tensorflow.org/versions/master/tutorials/layers>

<https://www.tensorflow.org/serving/tutorials/Serving_REST_simple>

```
Retrain:
python retrain_ORIG.py --bottleneck_dir=/tf_files/bottlenecks --how_many_training_steps=500 --model_dir=/tf_files/inception --output_graph=/tf_files/retrained_graph.pb --output_labels=/tf_files/retrained_labels.txt --image_dir=/tf_files/train_images/ --summaries_dir=/tmp/retrain_logs
```

## TensorBoard

```
tensorboard --logdir=name1:/path/to/logs/1,name2:/path/to/logs/2
```

### Commands

```
!saved_model_cli show --dir {export_path} --all

Example:
saved_model_cli show --dir train_strawberrydc_iter5_labEq_combo_augmented_both_167/saved_model --all
```

### To check versions

```
pip show keras
Name: Keras
Version: 2.1.2

pip show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.3.0
```

### Mask R-CNN

```
# How to convert COCO model (.h5) to tensorflow .pb mode
Ref: https://github.com/matterport/Mask_RCNN/issues/218

To produce h5:
python3 coco.py evaluate --dataset=$COCO_PATH --model=coco

To save model in coco.py:
evaluate_coco(model, dataset_val, coco, "bbox", limit=int(args.limit)) model.keras_model.save("mrcnn_eval.h5")

Extracting pb from h5:
python3 keras_to_tensorflow.py -input_model_file saved_model_mrcnn_eval.h5 -output_model_file model.pb -num_outputs=7
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bhabs.gitbook.io/allsetup/tensorflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
