Running the `bazel build` command to build a TensorFlow Python script is optional. You can just run the Python script directly. For example, we can run `python tensorflow/python/tools/freeze_graph.py` without building it first with `bazel build tensorflow/python/tools:freeze_graph` then running `bazel-bin/tensorflow/python/tools/freeze_graph`. But be aware that running the Python script directly will use the version of TensorFlow you’ve installed via pip, which may be different from the version you’ve downloaded as source and built by the `bazel build` command. This can be the cause of some confusing errors so be sure you know the TensorFlow version used to run a script. In addition, for a C++ based tool, you have to build it first with bazel before you can run it. For example, the `transform_graph` tool, which we'll see soon, is implemented in `transform_graph.cc` located at `tensorflow/tools/graph_transforms`; another important tool called `convert_graphdef_memmapped_format`, which we'll use for our iOS app later, is also implemented in C++ located at `tensorflow/contrib/util`.
Running the `bazel build` command to build a TensorFlow Python script is optional. You can just run the Python script directly. For example, we can run `python tensorflow/python/tools/freeze_graph.py` without building it first with `bazel build tensorflow/python/tools:freeze_graph` then running `bazel-bin/tensorflow/python/tools/freeze_graph`. But be aware that running the Python script directly will use the version of TensorFlow you’ve installed via pip, which may be different from the version you’ve downloaded as source and built by the `bazel build` command. This can be the cause of some confusing errors so be sure you know the TensorFlow version used to run a script. In addition, for a C++ based tool, you have to build it first with bazel before you can run it. For example, the `transform_graph` tool, which we'll see soon, is implemented in `transform_graph.cc` located at `tensorflow/tools/graph_transforms`; another important tool called `convert_graphdef_memmapped_format`, which we'll use for our iOS app later, is also implemented in C++ located at `tensorflow/contrib/util`.
If you don't have a good understanding of all these details, don't worry; to develop powerful mobile apps using a model built by others, you don't have to understand all the details, but in the next chapter we'll also discuss in greater detail how you can build a RNN model from scratch for stock prediction, and with that, you'll have a better understanding of all the RNN stuff.
If you don't have a good understanding of all these details, don't worry; to develop powerful mobile apps using a model built by others, you don't have to understand all the details, but in the next chapter we'll also discuss in greater detail how you can build a RNN model from scratch for stock prediction, and with that, you'll have a better understanding of all the RNN stuff.
...
@@ -120,10 +120,10 @@ drwxr-xr-x 2 jeff jeff 4096 Feb 12 00:11 eval
...
@@ -120,10 +120,10 @@ drwxr-xr-x 2 jeff jeff 4096 Feb 12 00:11 eval
请注意,`kernel`只是权重的另一个名称,`(4, 4)`,`(4, )`,`(4, 1)`和`(1, )`是权重的形状和对第一个(输入到隐藏)和第二层(隐藏到输出)。 如果您从 iPython 多次运行脚本,则`tf`对象的默认图形将包含先前运行的可训练变量,因此,除非调用`tf.reset_default_graph()`,否则需要使用`gvs = [(g, v) for g, v in gvs if g != None]`删除那些过时的训练变量, 将返回 None 梯度(有关`computer_gradients`的更多信息,请参见[这里](https://www.tensorflow.org/api_docs/python/tf/train/AdamOptimizer#compute_gradients))。
请注意,`kernel`只是权重的另一个名称,`(4, 4)`,`(4, )`,`(4, 1)`和`(1, )`是权重的形状和对第一个(输入到隐藏)和第二层(隐藏到输出)。 如果您从 iPython 多次运行脚本,则`tf`对象的默认图将包含先前运行的可训练变量,因此,除非调用`tf.reset_default_graph()`,否则需要使用`gvs = [(g, v) for g, v in gvs if g != None]`删除那些过时的训练变量, 将返回 None 梯度(有关`computer_gradients`的更多信息,请参见[这里](https://www.tensorflow.org/api_docs/python/tf/train/AdamOptimizer#compute_gradients))。