Можно ли передать массив в нейронной сети персептрон? - PullRequest
1 голос
/ 25 июня 2019

Я пытаюсь настроить нейронную сеть для идентификации волн Эллиотта, и мне было интересно, можно ли передать массив массивов в персептрон? Мой план - передать массив размера 4 ([Open, Close, High, Low]) в каждый персептрон. Если да, как будет работать расчет средневзвешенного значения и как я могу это сделать, используя библиотеку Python Keras? Спасибо!

1 Ответ

0 голосов
/ 25 июня 2019

Это довольно стандартная полностью подключенная нейронная сеть для построения.Я предполагаю, что у вас есть проблема классификации:

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
...