4 글 보임 - 1 에서 4 까지 (총 4 중에서)
-
글쓴이글
-
2022년 11월 24일 00:43 #55365
최은아참가자feature_columns = [] #빈 리스트안에 모두다 넣을거다. feature_columns.append( tf.feature_column.numeric_column('Fare') ) feature_columns.append( tf.feature_column.numeric_column('Parch') ) feature_columns.append( tf.feature_column.numeric_column('SibSp') ) feature_columns.append( tf.feature_column.numeric_column('Age') )
Age = tf.feature_column.numeric_column('Age')#뭉퉁그려서 넣을거 (나이) Age_bucket = tf.feature_column.bucketized_column(Age, boundaries=[10,20,30,40,50,60]) feature_columns.append( Age_bucket )
vocab = data['Sex'].unique()#원핫인코딩: 종류몇개없는 카테고리 (성별) cat = tf.feature_column.sequence_categorical_column_with_vocabulary_list('Sex', vocab) one_hot = tf.feature_column.indicator_column(cat) feature_columns.append( one_hot )
vocab = data['Embarked'].unique()#원핫인코딩: (클래스등급) cat = tf.feature_column.sequence_categorical_column_with_vocabulary_list('Embarked', vocab) one_hot = tf.feature_column.indicator_column(cat) feature_columns.append( one_hot )
vocab = data['Pclass'].unique()#원핫인코딩: (객실등급) cat = tf.feature_column.sequence_categorical_column_with_vocabulary_list('Pclass', vocab) one_hot = tf.feature_column.indicator_column(cat) feature_columns.append( one_hot )
#embedding vocab = data['Ticket'].unique()#임베딩: 종류가 넘 많은 카테고리(티켓이름) cat = tf.feature_column.sequence_categorical_column_with_vocabulary_list('Ticket', vocab) one_hot = tf.feature_column.embedding_column(cat, dimension = 9)#복잡한거 차원 만들어서 넣기 feature_columns.append( one_hot )
model = tf.keras.Sequential([ tf.keras.layers.DenseFeatures(feature_columns), tf.keras.layers.Dense(128, activation='relu'), tf.keras.layers.Dense(64, activation='relu'), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(1, activation='sigmoid'), ]) model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['acc']) ds_batch = ds.batch(32) model.fit(ds_batch, shuffle=True, epochs=20) WARNING:tensorflow:Layers in a Sequential model should only have a single input tensor. Received: inputs={'PassengerId': <tf.Tensor 'IteratorGetNext:5' shape=(None,) dtype=int64>, 'Pclass': <tf.Tensor 'IteratorGetNext:6' shape=(None,) dtype=int64>, 'Name': <tf.Tensor 'IteratorGetNext:3' shape=(None,) dtype=string>, 'Sex': <tf.Tensor 'IteratorGetNext:7' shape=(None,) dtype=string>, 'Age': <tf.Tensor 'IteratorGetNext:0' shape=(None,) dtype=float64>, 'SibSp': <tf.Tensor 'IteratorGetNext:8' shape=(None,) dtype=int64>, 'Parch': <tf.Tensor 'IteratorGetNext:4' shape=(None,) dtype=int64>, 'Ticket': <tf.Tensor 'IteratorGetNext:9' shape=(None,) dtype=string>, 'Fare': <tf.Tensor 'IteratorGetNext:2' shape=(None,) dtype=float64>, 'Embarked': <tf.Tensor 'IteratorGetNext:1' shape=(None,) dtype=string>}. Consider rewriting this model with the Functional API. feature_column에 넣지도 않은 'Name' 이 왜 나오는지 모르겠어요. 그리고 영상에서 Age 컬럼 두번이나 append되던데 맞나요? 잘 따라쳤는데... 어렵네용. 도와주세용~~~"
2022년 11월 24일 09:43 #55389
codingapple키 마스터텐서플로우 신버전에서 feature column 어쩌구가 지원중단되어서 텐서플로우 이전버전 쓰거나 import tensorflow.compat.v1 as tf1 tf1.keras.layers.DenseFeatures( 이렇게 쓰거나 합시다
2023년 4월 14일 14:57 #76759
최은성참가자import tensorflow.compat.v1 as tf1 tf1.keras.layers.DenseFeatures( 이것두 잘 안되네요;;
2023년 4월 14일 19:11 #76825
codingapple키 마스터https://www.tensorflow.org/tutorials/structured_data/feature_columns?hl=ko 신버전 문법 사용하는 수 밖에 없을듯요
-
글쓴이글
4 글 보임 - 1 에서 4 까지 (총 4 중에서)
- 답변은 로그인 후 가능합니다.