#๐ Attempted to make a simple Neural Network, but the results always end up being the same
5 messages ยท Page 1 of 1 (latest)
@thin geyser
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
import NeuralNetwork
model = NeuralNetwork.NeuralNetwork([])
input_layer = model.create_layer(2)
hidden_layer = model.create_layer(2)
output_layer = model.create_layer(1, activation=NeuralNetwork.sigmoid)
# AND
model.predict([1, 1], target=1)
model.train([[1, 1], [1, 0], [0, 1], [0, 0]], targets=[1, 1, 1, 0])
while True:
print('\n')
command = input(">> ")
full_command = command.split(' ')
if full_command[0] == "predict":
if full_command[1] == "1":
model.predict([1, 1], target=1)
elif full_command[1] == "2":
model.predict([1, 0], target=1)
elif full_command[1] == "3":
model.predict([0, 1], target=1)
elif full_command[1] == "4":
model.predict([0, 0], target=0)
if full_command[0] == "train":
old_error = model.error
for i in range(int(full_command[1])):
model.train([[1, 1], [1, 0], [0, 1], [0, 0]], targets=[1, 1, 1, 0])
print(f"Old Error: {old_error}\nNew Error: {model.error}")
if full_command[0] == "train0":
model.train([0,0], 0)
if full_command[0] == "allweights":
for layer in model.layers:
for neuron in layer:
print("Layer: ", model.layers.index(layer))
print("Weight:", neuron.weight)
print("Bias:", neuron.bias)
print("Output:", neuron.result)
Script Im using to train the model, attempting to train it to perform the OR function
@thin geyser
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.