小编emp*_*eon的帖子

可以使用S型激活函数来解决Keras中的回归问题吗?

我已经用R实现了简单的神经网络,但是这是我第一次使用Keras这样做,所以请多多指教。

我在Keras中开发了神经网络功能来预测汽车销量(数据集可在此处获得)。CarSales是因变量。

据我所知,Keras用于开发神经网络以进行分类而不是回归。到目前为止,在所有示例中,输出范围都在0到1之间。

这是我开发的代码,您将看到我正在使用'sigmoid'函数进行输出:

from tensorflow.python.keras.models import Sequential
from tensorflow.python.keras.layers import Dense
from tensorflow.python.keras.wrappers.scikit_learn import KerasRegressor
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import KFold
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import MinMaxScaler

import os;
path="C:/Users/cars.csv"
os.chdir(path)
os.getcwd()

#Variables
dataset=np.loadtxt("cars.csv", delimiter=",")
x=dataset[:,0:5]
y=dataset[:,5]
y=np.reshape(y, (-1,1))
scaler = MinMaxScaler()
print(scaler.fit(x))
print(scaler.fit(y))
xscale=scaler.transform(x)
yscale=scaler.transform(y)

model = Sequential()
model.add(Dense(12, input_dim=5, kernel_initializer='normal', activation='relu'))
model.add(Dense(8, activation='relu')) …
Run Code Online (Sandbox Code Playgroud)

python neural-network keras tensorflow

3
推荐指数
2
解决办法
2031
查看次数

标签 统计

keras ×1

neural-network ×1

python ×1

tensorflow ×1