해결하고자 하는 문제
Tensorflow 히든레이어 실습을 할 때
H = tf.keras.layers.Dense(10, activation='swish')(X) 이 부분에서 에러가 납니다.
에러 없이 히든레이어를 사용하고 싶습니다.
저의 개발 환경은 아나콘다 Spyder을 사용하고 있습니다.
이하는 제가 사용하고있는 라이브러리 버전 정보입니다.
Phthon 3.7.7
Tensorflow 2.1.0
Pandas 1.0.5
코드 혹은 오류
히든레이어
라이브러리 사용
import tensorflow as tf
import pandas as pd
import os
데이터 준비(prepare data)
current_directory = os.path.abspath(os.path.dirname(file))
file_path = current_directory + '/csv/boston.csv'
boston_data = pd.read_csv(file_path)
print(boston_data.columns)
print(boston_data)
독립변수(independent_variable), 종속변수(dependent_variable)
independent_variable = boston_data[['crim', 'zn', 'indus', 'chas', 'nox', 'rm', 'age', 'dis', 'rad', 'tax', 'ptratio', 'b', 'lstat']]
dependent_variable = boston_data[['medv']]
print(independent_variable.shape, dependent_variable.shape)
모델의 구조를 만듭니다.(Create the structure of a model.)
X = tf.keras.layers.Input(shape=[13])
H = tf.keras.layers.Dense(10, activation='swish')(X)
Y = tf.keras.layers.Dense(1)(H)
model = tf.keras.models.Model(X, Y)
model.compile(loss='mse')
모델을 학습합니다.(Learn(fit) model)
model.fit(independent_variable, dependent_variable, epochs=1000, verbose=0) # verbose=0 은 학습 하고있는 내용을 출력 안하게 해주는 명령
model.fit(independent_variable, dependent_variable, epochs=10)
모델을 이용합니다.(Use a model)
predict_result = model.predict(independent_variable[0:5])
#print(independent_variable[0:5])
print(predict_result)
print(dependent_variable[0:5])
'''
에러 내용
ValueError: Unknown activation function:swish
'''
환경
사용중인 운영체제, 언어, 라이브러리의 버전을 적어주세요.
시도해본 방법
해결하고자 하는 문제
Tensorflow 히든레이어 실습을 할 때
H = tf.keras.layers.Dense(10, activation='swish')(X) 이 부분에서 에러가 납니다.
에러 없이 히든레이어를 사용하고 싶습니다.
저의 개발 환경은 아나콘다 Spyder을 사용하고 있습니다.
이하는 제가 사용하고있는 라이브러리 버전 정보입니다.
Phthon 3.7.7
Tensorflow 2.1.0
Pandas 1.0.5
코드 혹은 오류
히든레이어
라이브러리 사용
import tensorflow as tf
import pandas as pd
import os
데이터 준비(prepare data)
current_directory = os.path.abspath(os.path.dirname(file))
file_path = current_directory + '/csv/boston.csv'
boston_data = pd.read_csv(file_path)
print(boston_data.columns)
print(boston_data)
독립변수(independent_variable), 종속변수(dependent_variable)
independent_variable = boston_data[['crim', 'zn', 'indus', 'chas', 'nox', 'rm', 'age', 'dis', 'rad', 'tax', 'ptratio', 'b', 'lstat']]
dependent_variable = boston_data[['medv']]
print(independent_variable.shape, dependent_variable.shape)
모델의 구조를 만듭니다.(Create the structure of a model.)
X = tf.keras.layers.Input(shape=[13])
H = tf.keras.layers.Dense(10, activation='swish')(X)
Y = tf.keras.layers.Dense(1)(H)
model = tf.keras.models.Model(X, Y)
model.compile(loss='mse')
모델을 학습합니다.(Learn(fit) model)
model.fit(independent_variable, dependent_variable, epochs=1000, verbose=0) # verbose=0 은 학습 하고있는 내용을 출력 안하게 해주는 명령
model.fit(independent_variable, dependent_variable, epochs=10)
모델을 이용합니다.(Use a model)
predict_result = model.predict(independent_variable[0:5])
#print(independent_variable[0:5])
print(predict_result)
print(dependent_variable[0:5])
'''
에러 내용
ValueError: Unknown activation function:swish
'''
환경
사용중인 운영체제, 언어, 라이브러리의 버전을 적어주세요.
시도해본 방법