Multiple objects somehow interfering with each other [original version]

前端 未结 1 569
别那么骄傲
别那么骄傲 2021-01-28 08:11

I have a neural network (NN) which works perfectly when applied to a single data set. However if I want to run the NN on, for example, one set of data and then create a new inst

相关标签:
1条回答
  • 2021-01-28 08:35

    Your error -- if there is one -- doesn't have anything to do with the class. As @Daniel Roseman suggested, the natural guess would be that it was a class/instance variable issue, or maybe a mutable default argument, or multiplication of a list, or something, the most common causes of mysterious behaviour.

    Here, though, you're getting different results only because you're using different random numbers each time. If you random.seed(0) before you call NN(2,3,1), you get exactly the same results:

    error 2.68110
    error 0.44049
    error 0.39256
    error 0.26315
    error 0.00584
    [ 0.01  0.01  0.07  0.97]
    error 2.68110
    error 0.44049
    error 0.39256
    error 0.26315
    error 0.00584
    [ 0.01  0.01  0.07  0.97]
    

    I can't judge whether your algorithm is right. Incidentally, I think your rand function is reinventing random.uniform.

    0 讨论(0)
提交回复
热议问题