2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AttributeError: 'tuple' object has no attribute 'layer'の対処

Posted at

#はじめに
株価の予測とか色々Kerasを使ってやろうとしたのだがエラーがでて混乱
結局は互換性がないimportをしていたのが原因
##環境
一応
windows10
python3.7
##起きたエラー

qiita.py
AttributeError: 'tuple' object has no attribute 'layer'

タプルなんてどこにも見当たらなくてどうしたものかと苦しんでいたら以下の投稿を発見
kerasとtf.kerasの差分と互換検証 #1
読んでみるとこのように書いてあった

※2の実行時エラー発生(tf-kerasのModelにmb-kerasのLayerを突っ込む)
AttributeError: 'tuple' object has no attribute 'layer't

どうやら互換性がないものを突っ込むとこのようなエラーが起きるらしい
##対処法

qiita.py
import numpy as np
from tensorflow.keras.models import Model
from sklearn.model_selection import train_test_split
from keras.layers import Input, Dense, LSTM,concatenate,MaxPooling1D
from sklearn.preprocessing import StandardScaler

上記が元のimport
2行目と4行目があっていないので合わせたのが下記のimport

qiita.py
import numpy as np
from tensorflow.keras.models import Model
from sklearn.model_selection import train_test_split
from tensorflow.keras.layers import Input, Dense, LSTM,concatenate,MaxPooling1D
from sklearn.preprocessing import StandardScaler

おわり

2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?