Python comparing two numbers is incorrect

时间:2018-06-05 05:10:26

标签: python debugging comparison

As the title suggests, i have two numbers target and B, when i compare them it says they don't equal each other, but they both give the same output.

import numpy

def node(m1,m2,w1,w2,b):
  z= m1*w1+m2*w2+b
  return seg(z)

def seg(y):
  return 1/(1+numpy.exp(-y))

w1= numpy.random.randn()
w2= numpy.random.randn()
b= numpy.random.randn()
target =4.0

def slope(b):
  return 2*(b-target)
i=0
while b != target:
  b= b-.1*slope(b)
  i=i+1
  if(i==128):
    break

print( b == target)
print(target)
print(b)

0 个答案:

没有答案