jeudi 3 janvier 2019

Unzeroing function in Python AI not working (Specific code needs to be seen)

Background: I am trying to make a CNN that doesn't use Keras or other CNN layer API(other than scipy on convolution, for the simplicity of the math). I have been doing well so far, but I noticed most of my code was redundant, and could be shortened using for loops and functions, so I redo my code using this change. Note, before I did the change, everything worked. Now that I turned everything into functions instead of pieces of code, the reduced parts don't work.

Code explanation: If you go to the code from the link above and look around the middle, you will see two functions, loadw and unzero. Previously, these were two functions, but for later use of unzero I decided to break them down. Don't recommend combining! Anyways, what loadw does is it takes a weight variable and checks if it is already saved to mvars.txt. If it isn't, it randomly initializes it using the Gaussian, takes the absolute value, and takes the ceiling function. Finally, it saves the variable to the file. unzero basically checks if the input is 0, and if it is, it initializes it the same way, and then saves it. Next, if you look down at the w's(1,2,3,4), you will see that I initialize each using loadw, and then unzero them. I proceed to do a little bit of math with them, and then I leave them. I don't touch them till the very end when I print them.

Problem: (Check the code output) Now, if you just look at the output and don't focus on the numbers, you say, "oh, no problems!" However, you can see that the code outputs all zeros. Nothing else. Every number there depends on the w's. The w's themselves are the second section. My unzero code should make sure that if the input(w)is 0, it makes it something else. Could the problem be in every part of the code? Or the pickling? Or maybe the unzero doesn't work? I have no clue myself, I've asked multiple friends who used these functions I've made in their own AI, and it works for them.

Lastly, three comments. 1. I know much of the code is recessive, but I am trying to be as defensive as possible. 2. This code isn't a full-fledged AI yet, I have only finished the convolution and weights. 3. Try not to be hateful. My experience(and my friends') is that stack exchange communities tend not to be the nicest in their replies, so if you have something negative to say, I'd rather not hear it :). Also, I already know someone is going to downvote this for not being a specific question......

Thanks for reading all this! I couldn't come up with a TL;DR that effectively held all the important info together. Sorry about that!




Aucun commentaire:

Enregistrer un commentaire