Hello friends i have problem with sintaxis in numpy to create raw input , i not sure but i think i should make it float , if so please your help how to do it correct , the error i get is :
Traceback (most recent call last):
File "eva.py", line 76, in <module>
result = sigmoid(np.dot(single_point, weights) + bias)
TypeError: Cannot cast array data from dtype('float64') to dtype('S32') according to the rule 'safe'
here is the script :
import numpy as np
feature_set = np.array([[0,1,0],[0,0,1],[1,0,0],[1,1,0],[1,1,1]])
labels = np.array([[1,0,0,1,1]])
labels = labels.reshape(5,1)
np.random.seed(42)
weights = np.random.rand(3,1)
bias = np.random.rand(1)
lr = 0.05
print 'data test chart '
print
print ' con=1 con=2 con=3 Result'
print
print ' A 0 1 0 1'
print ' B 0 0 1 0'
print ' C 1 0 0 0'
print ' D 1 1 0 1'
print ' E 1 1 1 1'
print
W1 = raw_input(" Con1 : ")
W2 = raw_input(" Con2 : ")
W3 = raw_input(" Con3 : ")
def sigmoid(x):
return 1/(1+np.exp(-x))
def sigmoid_der(x):
return sigmoid(x)*(1-sigmoid(x))
for epoch in range(20000):
inputs = feature_set
XW = np.dot(feature_set, weights) + bias
z = sigmoid(XW)
error = z - labels
print(error.sum())
dcost_dpred = error
dpred_dz = sigmoid_der(z)
z_delta = dcost_dpred * dpred_dz
inputs = feature_set.T
weights -= lr * np.dot(inputs, z_delta)
for num in z_delta:
bias -= lr * num
single_point = np.array([W1,W2,W3])
result = sigmoid(np.dot(single_point, weights) + bias)
print(result)
my problem in this line : single_point = np.array([W1,W2,W3]), its not want accept raw input , please your help .Thank you .