I am a total newbie when it comes to neural networks, but my basic
question is, if you have an output for a neural network that can have
multiple right answers, what is a good "desired output" to give it for
Also, if you notice any other glaring errors in my approach
(inappropriate neural network size, wrong algorithm, too small/large
training size), please tell me.
My specific details are below:
I'm trying to use a neural network (specifically, FANN) to help speed
up bitcoin mining. If you are unfamiliar with bitcoin, check it out
at: bitcoin.org . For bitcoin mining, the basic idea is that you have
a set of data, and a 32 bit nonce. You are tasked to choose difference
nonces so that the result of performing the SHA256 hash twice will
result in an 512 bit output number that is equal to or less than a
For example, the target could be
It will have succeeded if it chooses a nonce so the hash is less than
the target. For example, the following would be a success:
My hope is that a NN could choose nonces that were more likely to
succeed than others. Here is what I tried so far.
I create an ANN (details at the bottom of this message with 224 inputs
and 32 outputs, which represents the 224 bit values of the data being
hashed and the 32 bits that are the nonce.
I then took actual live data from bitcoin, feeding in the 224 input
bits and having the neural network choose a 32 bit nonce as a set of
32 floats which range from (-1 to 1).
Then I rounded each of the float bits to either -1 or 1, and
translated that so -1 == 0 and 1 == 1. This I set as the starting
point, or "best guess".
From there I continually calculated the SHA256 hash as the bitcoin
code does, and updated the best guess by flipping bits iteratively in
binary counting style, starting with the outputs that were closest to
zero (ie. where the NN was the least decided on what the bit should
be) until I found a hash under the hash target value.
For example, suppose there were only 4 bits of output instead of 32
for simplicity. if for a given training example the NN came up with
This would translate to a guess of 0101. Then I hash it, and if it was
not below the target, I flip the bits as follows
^--- flipped first because 0.1 is closest to zero
^- flipped second because -0.3 is second closest to zero
^-^-- both flipped
^-- -0.8 is third closest to zero
^^-- and so on.. basic binary iteration
... (and so on)
The above yields a total number of tries before a successful hash has
been found. I use this number as an error amount. Since there are
multiple solutions, I'm not sure what to give as a "desired output"
for back propagation. I've tried these ideas but both with absolute no
success after 10,000 trainings each:
1. Use the nonce that produced the target after bit flipping from the
2. Use a random value and compute a strength of error based on num
tries: 1. - (x) / ( (x) + (num_tries) )
where (x) is a constant. Then choose a "desired output" for back
propagation with: (actual output) * (1 - (strength of error)) + (1 or
-1 randomly) * (strength of error)
for each output
3. A combination of 1 and 2, where I use the result from 1 and the
strength computed from 2 to come up with a "desired output"
Neural network settings:
Library: Fast Artificial Neural Network Library (FANN) http://leenissen.dk/
Activation function: Sigmoid Symetric
Num inputs: 224
Hidden layer 1: 168
Hidden layer 2: 112
Hidden layer 3: 56
Num outputs: 56
Num trainings: 10,000 - each train a unique input.
I also tried a networks with 1 hidden layer of 112 neurons.