Skip to content

Commit

Permalink
JA translations
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyaspiridonov committed Dec 16, 2023
1 parent 5e0c422 commit 4d5f346
Show file tree
Hide file tree
Showing 43 changed files with 3,786 additions and 285 deletions.
4 changes: 3 additions & 1 deletion site/ja/agents/tutorials/0_intro_rl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
"\n",
"Q 学習は Q 関数の概念に基づいています。ポリシー $\\pi$, $Q^{\\pi}(s, a)$ のQ関数(状態アクション値関数)は、最初に $a$ を実行し、その後にポリシー $\\pi$ を実行し、状態 $s$ から得られる予期される報酬または割引された報酬の合計を測定します。最適な Q 関数 $Q^*(s, a)$ は、観測 $s$ から開始して、行動 $a$ を実行し、その後最適なポリシーを実行する場合に取得可能な最大の報酬として定義します。最適な Q 関数は、次の*ベルマン*最適化方程式に従います。\n",
"\n",
"```\n",
"$\\begin{equation}Q^\\ast(s, a) = \\mathbb{E}[ r + \\gamma \\max_{a'} Q^\\ast(s', a') ]\\end{equation}$\n",
"```\n",
"\n",
"つまり、状態 $s$ と行動 $a$ からの最大のリターンは、即時の報酬 $r$ とエピソードの最後まで最適なポリシーに従うことによって得られるリターン ($\\gamma$ で割引) の合計です。 (つまり、次の状態 $s'$ からの最大報酬)。予測値は、即時の報酬 $r$ と可能な次の状態 $s'$ の両方の分布に対して計算されます。\n",
"\n",
Expand All @@ -110,7 +112,7 @@
"\n",
"ほとんどの問題では、$Q$ 関数を $s$ と $a$ の各組み合わせの値を含む表として示すことは現実的ではありません。代わりに、Q 値を推定するために、パラメータ $\\theta$ を使用するニューラルネットワークなどの関数近似器 ($Q(s, a; \\theta) \\approx Q^*(s, a)$をトレーニングします。) 各ステップ $i$ では、次の損失を最小限に抑えます。\n",
"\n",
"$\\begin{equation}L_i(\\theta_i) = \\mathbb{E}*{s, a, r, s'\\sim \\rho(.)} \\left[ (y_i - Q(s, a; \\theta_i))^2 \\right]\\end{equation}$ where $y_i = r + \\gamma \\max*{a'} Q(s', a'; \\theta_{i-1})$\n",
"$\\begin{equation}L_i(\\theta_i) = \\mathbb{E}{em0}{s, a, r, s'\\sim \\rho(.)} \\left[ (y_i - Q(s, a; \\theta_i))^2 \\right]\\end{equation}$ where $y_i = r + \\gamma \\max{/em0}{a'} Q(s', a'; \\theta_{i-1})$\n",
"\n",
"ここで、$y_i$は TD (時間差) ターゲットと呼ばれ、$y_i - Q$ は TD エラーと呼ばれます。環境から収集された $\\rho$ は動作の分布、遷移 ${s, a, r, s'}$ の分布を表します。\n",
"\n",
Expand Down
207 changes: 207 additions & 0 deletions site/ja/community/contribute/docs_ref.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
# TensorFlow API ドキュメントへの貢献

<a id="doctest"></a>

## テスト可能なドキュメンテーション文字列

TensorFlow は [DocTest](https://docs.python.org/3/library/doctest.html) を使用して Python ドキュメント文字列(docstring)のコードスニペットをテストします。スニペットは、実行可能な Python コードである必要があります。テストを有効にするには、行の先頭に `>>>`(3 つの右山括弧)を追加します。例えば、以下は <a>array_ops.py</a> ソースファイルの <code>tf.concat</code> 関数からの抜粋です。

```
def concat(values, axis, name="concat"):
"""Concatenates tensors along one dimension.
...
>>> t1 = [[1, 2, 3], [4, 5, 6]]
>>> t2 = [[7, 8, 9], [10, 11, 12]]
>>> concat([t1, t2], 0)
<tf.Tensor: shape=(4, 3), dtype=int32, numpy=
array([[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9],
[10, 11, 12]], dtype=int32)>
<... more description or code snippets ...>
Args:
values: A list of `tf.Tensor` objects or a single `tf.Tensor`.
axis: 0-D `int32` `Tensor`. Dimension along which to concatenate. Must be
in the range `[-rank(values), rank(values))`. As in Python, indexing for
axis is 0-based. Positive axis in the rage of `[0, rank(values))` refers
to `axis`-th dimension. And negative axis refers to `axis +
rank(values)`-th dimension.
name: A name for the operation (optional).
Returns:
A `tf.Tensor` resulting from concatenation of the input tensors.
"""
<code here>
```

Note: TensorFlow DocTest uses TensorFlow 2 and Python 3.

To assess reference documentation quality, see the example section of the
[TensorFlow 2 API Docs advice](https://docs.google.com/document/d/1e20k9CuaZ_-hp25-sSd8E8qldxKPKQR-SkwojYr_r-U/preview).
(Be aware that the Task Tracker on this sheet is no longer in use.)


### Make the code testable with DocTest

Currently, many docstrings use backticks (```) to identify code. To make the
code testable with DocTest:

* Remove the backticks (```) and use the left-brackets (>>>) in front of each
line. Use (...) in front of continued lines.
* Add a newline to separate DocTest snippets from Markdown text to
render properly on tensorflow.org.

### Customizations

TensorFlow uses a few customizations to the builtin doctest logic:

* It does not compare float values as text: Float values are extracted from
the text and compared using `allclose` with _liberal `atol` and `rtol`
tolerences_. This allows :
* Clearer docs - Authors don't need to include all decimal places.
* More robust tests - Numerical changes in the underlying implementation
should never cause a doctest to fail.
* It only checks the output if the author includes output for a line. This
allows for clearer docs because authors usually don't need to capture
irrelevant intermediate values to prevent them from being printed.

### Docstring considerations

* *Overall*: The goal of doctest is to provide documentation, and confirm that
the documentation works. This is different from unit-testing. So:
* Keep examples simple.
* Avoid long or complicated outputs.
* Use round numbers if possible.
* *Output format*: The output of the snippet needs to be directly beneath the
code that’s generating the output. Also, the output in the docstring has to
be exactly equal to what the output would be after the code is executed. See
the above example. Also, check out
[this part](https://docs.python.org/3/library/doctest.html#warnings) in the
DocTest documentation. If the output exceeds the 80 line limit, you can put
the extra output on the new line and DocTest will recognize it. For example,
see multi-line blocks below.
* *Globals*: The <code>`tf`</code>, `np` and `os` modules are always
available in TensorFlow's DocTest.
* *Use symbols*: In DocTest you can directly access symbols defined in the
same file. To use a symbol that’s not defined in the current file, please
use TensorFlow’s public API `tf.xxx` instead of `xxx`. As you can see in the
example below, <code>`random.normal`</code> is accessed via
<code>`tf.random.normal`</code>. This is because
<code>`random.normal`</code> is not visible in `NewLayer`.

```
def NewLayer():
"""This layer does cool stuff.
Example usage:
>>> x = tf.random.normal((1, 28, 28, 3))
>>> new_layer = NewLayer(x)
>>> new_layer
<tf.Tensor: shape=(1, 14, 14, 3), dtype=int32, numpy=...>
"""
```
* *Floating point values*: The TensorFlow doctest extracts float values from
the result strings, and compares using `np.allclose` with reasonable
tolerances (`atol=1e-6`, `rtol=1e-6`). This way authors do not need to worry
about overly precise docstrings causing failures due to numerical issues.
Simply paste in the expected value.
* *Non-deterministic output*: Use ellipsis(`...`) for the uncertain parts and
DocTest will ignore that substring.
```
>>> x = tf.random.normal((1,))
>>> print(x)
<tf.Tensor: shape=(1,), dtype=float32, numpy=..., dtype=float32)>
```
* *Multi-line blocks*: DocTest is strict about the difference between a single
and a multi-line statement. Note the usage of (...) below:
```
>>> if x > 0:
... print("X is positive")
>>> model.compile(
... loss="mse",
... optimizer="adam")
```
* *Exceptions*: Exception details are ignored except the Exception that’s
raised. See
[this](https://docs.python.org/3/library/doctest.html#doctest.IGNORE_EXCEPTION_DETAIL)
for more details.
```
>>> np_var = np.array([1, 2])
>>> tf.keras.backend.is_keras_tensor(np_var)
Traceback (most recent call last):
...
ValueError: Unexpectedly found an instance of type `<class 'numpy.ndarray'>`.
```
### Use a project-local copy of tf-doctest.
Note: The tf-doctest utility is only setup to test source files within the
`tensorflow` repository. If the files you are editing are in TensorFlow you can
skip to the next section. Otherwise keep reading this section.
Some API's in TensorFlow come from an external project:
* `tf.estimator` (from
[tensorflow_estimator](https://github.com/tensorflow/estimator))
* `tf.summary` [tensorboard](https://github.com/tensorflow/tensorboard))
* `tf.keras.preprocessing` (from
[keras-preprocessing](https://github.com/keras-team/keras-preprocessing))
If you're working on an external project, or on TensorFlow APIs that are housed
in an external project, these instructions won't work unless that project has
its own local copy of `tf_doctest`, and you use that copy instead of
TensorFlow's.
For example:
[tf_estimator_doctest.py](https://github.com/tensorflow/estimator/python/estimator/tf_estimator_doctest.py).
### Test on your local machine
There are two ways to test the code in the docstring locally:
* If you are only changing the docstring of a class/function/method, then you
can test it by passing that file's path to
[tf_doctest.py](https://www.tensorflow.org/code/tensorflow/tools/docs/tf_doctest.py).
For example:
<pre class="prettyprint lang-bsh">
<code class="devsite-terminal">python tf_doctest.py --file=<file_path>
</pre>
This will run it using your installed version of TensorFlow. To be sure
you're running the same code that you're testing:
* Use an up to date [tf-nightly](https://pypi.org/project/tf-nightly/)
`pip install -U tf-nightly`
* Rebase your pull request onto a recent pull from
[TensorFlow's](https://github.com/tensorflow/tensorflow) master branch.
* If you are changing the code and the docstring of a class/function/method,
then you will need to
[build TensorFlow from source](../../install/source.md). Once you are setup
to build from source, you can run the tests:
<pre class="prettyprint lang-bsh">
bazel run //tensorflow/tools/docs:tf_doctest
</pre>
or
<pre class="prettyprint lang-bsh">
bazel run //tensorflow/tools/docs:tf_doctest -- --module=ops.array_ops
</pre>
The `--module` is relative to `tensorflow.python`.
```
2 changes: 1 addition & 1 deletion site/ja/community/forums.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# メーリングリスト

私たちはコミュニティとして、公開メーリングリストで数多くのコラボレーションを行っています。TensorFlow の使用に関するヘルプを探している場合は、まず、[TensorFlow Forum](https://discuss.tensorflow.org/)[Stack Overflow](https://stackoverflow.com/questions/tagged/tensorflow)、および [GitHub issues](https://github.com/tensorflow/tensorflow/issues) を確認してください。
私たちはコミュニティとして、公開メーリングリストで数多くのコラボレーションを行っています。TensorFlow の使用に関するヘルプをお探しの場合は、まず、[TensorFlow Forum](https://discuss.tensorflow.org/)[Stack Overflow](https://stackoverflow.com/questions/tagged/tensorflow)、および [GitHub issues](https://github.com/tensorflow/tensorflow/issues) を確認してください。TensorFlow チームが四半期ごとに発行している更新情報のまとめを受け取るには、[TensorFlow ニュースレター](https://services.google.com/fb/forms/tensorflow/)を購読してください

## TensorFlow 全般のリストとフォーラム

Expand Down
2 changes: 1 addition & 1 deletion site/ja/datasets/dataset_collections.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
" <td><a target=\"_blank\" href=\"https://www.tensorflow.org/datasets/dataset_collections\"><img src=\"https://www.tensorflow.org/images/tf_logo_32px.png\">TensorFlow.org で表示</a></td>\n",
" <td><a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/docs-l10n/blob/master/site/ja/datasets/dataset_collections.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\">Google Colab で実行</a></td>\n",
" <td><a target=\"_blank\" href=\"https://github.com/tensorflow/docs-l10n/blob/master/site/ja/datasets/dataset_collections.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\">GitHub で表示</a></td>\n",
" <td><a target=\"_blank\" href=\"https://github.com/tensorflow/datasets/blob/master/docs/dataset_collections.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\">GitHub で表示</a></td>\n",
" <td><a href=\"https://storage.googleapis.com/tensorflow_docs/docs-l10n/site/ja/datasets/dataset_collections.ipynb\"><img src=\"https://www.tensorflow.org/images/download_logo_32px.png\">ノートブックをダウンロード</a></td>\n",
"</table>"
]
Expand Down
6 changes: 3 additions & 3 deletions site/ja/datasets/overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"source": [
"# TensorFlow Datasets\n",
"\n",
"TFDS は、TensorFlowJax、およびその他の機械学習フレームワークですぐに使用できる一連のデータセットを提供しています。\n",
"TFDS provides a collection of ready-to-use datasets for use with TensorFlow, Jax, and other Machine Learning frameworks.\n",
"\n",
"データの確定的なダウンロードと準備、および `tf.data.Dataset`(または `np.array`)の構築を行います。\n",
"It handles downloading and preparing the data deterministically and constructing a `tf.data.Dataset` (or `np.array`).\n",
"\n",
"注意: [TFDS](https://www.tensorflow.org/datasets)(このライブラリ)と `tf.data`(有効なデータパイプラインを構築する TensorFlow API)を混同しないようにしてください。TFDS `tf.data` を囲む高レベルのラッパーです。この API をよく知らない方は、まず [ tf.data の公式ガイド](https://www.tensorflow.org/guide/data)を読むことをお勧めします。\n"
"Note: Do not confuse [TFDS](https://www.tensorflow.org/datasets) (this library) with `tf.data` (TensorFlow API to build efficient data pipelines). TFDS is a high level wrapper around `tf.data`. If you're not familiar with this API, we encourage you to read [the official tf.data guide](https://www.tensorflow.org/guide/data) first.\n"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion site/ja/guide/core/logistic_regression_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
"$$Y = \\frac{e^{z}}{1 + e^{z}} = \\frac{1}{1 + e^{-z}}$$\n",
"```\n",
"\n",
"式 $\\frac{1}{1 + e^{-z}}$ は、[シグモイド関数](https://developers.google.com/machine-learning/glossary#sigmoid_function){:.external} $\\sigma(z)$ として知られています。したがって、ロジスティック回帰の式は $Y = \\sigma(wX + b)$ と記述することができます。\n",
"式 $\\frac{1}{1 + e^{-z}}$ は、<a>シグモイド関数</a>{:.external} $\\sigma(z)$ として知られています。したがって、ロジスティック回帰の式は $Y = \\sigma(wX + b)$ と記述することができます。\n",
"\n",
"線形出力 `(-∞, ∞)` を `0` と `1` の間に変換するシグモイド関数を視覚化することから始めます。シグモイド関数は `tf.math.sigmoid` で利用できます。\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion site/ja/guide/core/matrix_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
"id": "TkiVUxeaQybq"
},
"source": [
"まず、与えられた行列の階数 r 近似を計算する関数を記述します。この低階数近似手順は、画像圧縮に使用されます。したがって、各概算の物理データサイズを計算することにも役立ちます。 次に、元の行列 $\\mathrm{A}$ の階数 r 近似 $\\mathrm{A}_r$ と誤差行列 $|\\mathrm{A} - \\mathrm{A}_r|$ を視覚化する関数を記述します。"
"まず、与えられた行列のランク r 近似を計算する関数を記述します。この低ランク近似手順は、画像圧縮に使用されます。したがって、各概算の物理データサイズを計算することにも役立ちます。単純化するために、ランク r 近似行列のデータサイズが、近似を計算するために必要な要素数の合計に等しいと仮定します。次に、元の行列 $\\mathrm{A}$ のランク r 近似 $\\mathrm{A}_r$ と誤差行列 $|\\mathrm{A} - \\mathrm{A}_r|$ を視覚化する関数を記述します。"
]
},
{
Expand Down
Loading

0 comments on commit 4d5f346

Please sign in to comment.