首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >可以将数组传递到神经网络感知器中吗?

可以将数组传递到神经网络感知器中吗?
EN

Stack Overflow用户
提问于 2019-06-25 06:03:39
回答 1查看 1.2K关注 0票数 2

我正在尝试建立一个神经网络来识别Elliott波,我想知道是否可以将一个数组数组传递到感知器中?我的计划是在每个感知器中传入一个大小为4 (Open,Close,High,Low)的数组。如果是这样,加权平均计算是如何工作的,我如何使用Python Keras库来实现这一点?谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-25 07:45:42

这是一个非常标准的完全连接的神经网络。我假设你有一个分类问题:

代码语言:javascript
运行
复制
from keras.layers import Input, Dense
from keras.models import Model

# I assume that x is the array containing the training data
# the shape of x should be (num_samples, 4)
# The array containing the test data is named y and is 
# one-hot encoded with a shape of (num_samples, num_classes)
# num_samples is the number of samples in your training set
# num_classes is the number of classes you have
# e.g. is a binary classification problem num_classes=2

# First, we'll define the architecture of the network
inp = Input(shape=(4,)) # you have 4 features
hidden = Dense(10, activation='sigmoid')(inp)  # 10 neurons in your hidden layer
out = Dense(num_classes, activation='softmax')(hidden)  

# Create the model
model = Model(inputs=[inp], outputs=[out])

# Compile the model and define the loss function and optimizer
model.compile(loss='categorical_crossentropy', optimizer='adam', 
              metrics=['accuracy'])
# feel free to change these to suit your needs

# Train the model
model.fit(x, y, epochs=10, batch_size=512)
# train the model for 10 epochs with a batch size of 512
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56744482

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档