Ich habe ein Problem mit neuronalen Netzwerk, das ich mit numpy und Pandas als meine Abhängigkeiten erstellen möchte. Das Netzwerk sollte die Größe eines Erdbebens anhand von Datum, Uhrzeit, Breite und Länge als Merkmale vorhersagen. Hier ist von Dataset-Snippet:Neuronales Netzwerk - TypeError: kann die Sequenz nicht durch Nicht-Int des Typs 'float' multiplizieren
Date Time Latitude Longitude Magnitude
0 01/02/1965 13:44:18 19.246 145.616 6.0
1 01/04/1965 11:29:49 1.863 127.352 5.8
2 01/05/1965 18:05:58 -20.579 -173.972 6.2
3 01/08/1965 18:49:43 -59.076 -23.557 5.8
4 01/09/1965 13:32:50 11.938 126.427 5.8
Und hier Code:
import pandas as pd
import numpy as np
data = pd.read_csv("C:/Users/Kamalov/AppData/Local/Programs/Python/Python35/my_code/datasets/database.csv")
train, test = data[:15000], data[15000:]
trainX, trainY = train[["Date","Time","Latitude","Longitude"]], train['Magnitude']
testX, testY = test[["Date","Time","Latitude","Longitude"]], test['Magnitude']
def sigmoid(x):
output = 1/(1+np.exp(-x))
return output
def sigmoid_output_to_derivative(output):
return output*(1-output)
synapse_0 = 2*np.random.random((4,1)) - 1
synapse_1 = 2*np.random.random((1,4)) - 1
X = trainX.values
y = trainY.values
for iter in range(50000):
# forward propagation
layer_0 = X
layer_1 = sigmoid(np.dot(layer_0,synapse_0))
layer_2 = sigmoid(np.dot(layer_1,synapse_1))
# how much did we miss?
layer_2_error = layer_2 - y
# multiply how much we missed by the
# slope of the sigmoid at the values in l1
layer_2_delta = layer_2_error * sigmoid_output_to_derivative(layer_2)
synapse_0_derivative = np.dot(layer_0.T,layer_2_delta)
# update weights
synapse_0 -= synapse_0_derivative
print ("Output After Training:")
print (layer_2)
Ich erhalte
"can't multiply sequence by non-int of type 'float'"
Fehler, auch wenn ich meine Datenrahmen umgewandelt numpy Array.
Jede Hilfe ist willkommen:/
Der Fehler sagt Ihnen wahrscheinlich genau, wo in Ihrem Code es auftritt. Warum verstecken Sie das vor uns? Außerdem ist das ein häufiger Python-Fehler und googling wird Ihnen sagen, in welchen Fällen dieser auftritt. Die Kombination dieser beiden Hinweise sollte Ihnen helfen, dies zu beheben. – sascha