LoginSignup
5
3

More than 5 years have passed since last update.

TensorFlowでTypeErrorが出て頭を抱えた

Posted at

TypeError: DataType float32 for attr 'T' not in list of allowed values: int32, int64
 こんなエラー.

 原因は,わかってみれば何てことはない.
 行列の行数や列数に,少数を指定しようとしてしまっていた.

 私の場合は,tf.truncated_normalの第一引数 shape に渡すPython arrayに IMAGE_SIZE/4 という数式を入れておいたのだが,この割り算の結果が少数になっていたため,エラーが出ていた.int()で囲って解決.

 TensorFlowは,intとfloatの間のcastを非明示的にはしてくれないので,他にも例えば,tf.scalar_summaryで学習途中の数値を後でグラフ化するために保存しておく場合でも,intの場合は事前にtf.castでfloatにキャストしておかなければいけなかったりする.

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3