tensorflow / tensorflow/java

NdArray implementations don't throw IllegalRankException as documented if no coordinates provided

オープン
#224 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Java
スター
928
フォーク
227
PR マージ指標
30日以内にマージされた PR はありません

説明

Instead, when no coordinates are provided, we return the scalar at (0, 0, ...). Is this an important idiom that we are preserving, or a questionable choice, or simply a bug?

Here's an example of an abstract method of FloatNdArray that is documented to throw IllegalRankException:

 /**
   * Returns the float value of the scalar found at the given coordinates.
   *
   * . . .
   *
   * @param coordinates coordinates of the scalar to resolve
   * @return value of that scalar
   * @throws IndexOutOfBoundsException if some coordinates are outside the limits of their respective dimension
   * @throws IllegalRankException if number of coordinates is not sufficient to access a scalar element
   */
  float getFloat(long... coordinates);

Here's the implementation in FloatDenseNdArray:

  @Override
  public float getFloat(long... indices) {
    return buffer.getFloat(positionOf(indices, true));
  }

But if indices.length == 0, then positionOf does not throw the claimed IllegalRankException:

  long positionOf(long[] coords, boolean isValue) {
    if (coords == null || coords.length == 0) {
      return 0;
    }
    Validator.coordinates(dimensions, coords, isValue);
    return dimensions.positionOf(coords);
  }

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

文書化された FloatNdArray.getFloat の契約から始め、FloatDenseNdArray.getFloat および positionOf と比較します。特に、座標がゼロの場合の分岐を確認してください。位置 0 のスカラーを返すことが意図された動作なのか、それとも文書化された例外動作に違反するのかを判断します。プロジェクトで関連するテストカバレッジが提供されている場合はそれを追加または更新し、動作とそのドキュメントが一致すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
machine-learning
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。