Neural networks with tensorflow in python without training

135 views Asked by At

I am making a very basic artificial life simulation with neural nets controlling the 'creatures'. I have made my own version for my first couple of tries, with limited success. I have decided to use TensorFlow for the time being (or any library can work). The problem is I want a way to input the inputs an weights, and receive the output, without the net trying to train itself(as is done in all tutorials and examples I could find. I will include my own code in the end, so if there is an easy solution for that, that would be the best, although libraries will make it easier for early tests.

def nn(n, s1, s2):
    hidden_layer = []
    out = []
    tot = 0
    for p in range(mid_num):
        tot = 0
        for u in range(len(n)):
            tot += s1[u * mid_num + p] * n[u]
        hidden_layer.append(tot)
        tot = 0
    for p in range(output_num):
        for u in range(len(hidden_layer)):
            tot += s2[u * output_num + p] * hidden_layer[u]
        out.append(round(sigmoid(tot / 53000)))
        # print(tot)
        tot = 0
    # print(out)
    return out
1

There are 1 answers

0
prometeu On BEST ANSWER

If you want the weights to be mere constants, so they are just matrix multiplications, you can use tf.constant. If you want to switch between trainable and not trainable weights, use tf.get_variables('weights', trainable=False); than switch True or False.