D
D
davamar2021-10-18 23:18:04
Python
davamar, 2021-10-18 23:18:04

I decided to try to write a neural network based on the Howdy Ho video (Do-it-yourself neural network in 10 minutes). Something went wrong?

Below is my code written in Python. The problem is on line 19. Exception occurred: ValueError (note: full exception trace is shown but execution is paused at: )
shapes (4,1) and (3,1) not aligned: 1 (dim 1) != 3 (dim 0)
File "D :\VS CODE\import math.py", line 19, in (Current frame)
outputs = sigmoid( np.dot(input_layer, synaptic_weights) )
How do I fix this? And please, for now, I’m an ordinary teapot, because if you can not load programmers with slang very much))))
https://www.youtube.com/watch?v=WFYxpi3O950 - link to the video that I followed

import numpy as np

def sigmoid(x):
    return 1 / (1 + np.exp(-x))

training_inputs = np.array()

training_outputs = np.array().T

np.random.seed(1)

synaptic_weights = 2 * np.random.random((3,1)) -1

print("Случайные инициалищирующие веса:")
print(synaptic_weights)

for i in range(20000):
    input_layer = training_outputs
    outputs = sigmoid( np.dot(input_layer, synaptic_weights) )
    
err = training_outputs - outputs
adjustments = np.dot( input_layer.T, err * (outputs * (1-outputs)) )
    
synaptic_weights += adjustments
print ("Весы после обучения: ")
print (synaptic_weights)

print("Результат:" )
print(outputs)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xandox, 2021-10-19
@xandox

Your caps don't match. Quite a popular problem. Helps the output of all shapes and careful examination of the output

for i in range(20000):
    input_layer = training_outputs # тут должен быть training_inputs, скорее всего и не весь, а по индексу
    outputs = sigmoid( np.dot(input_layer, synaptic_weights) )

To be honest, the whole code looks like nonsense. It will not teach anything, even if you fix the problem with shapes. Probably need to watch the video again.

E
Eugene Lerner, 2021-10-21
@ehevnlem

A program for a neural network is a task for a fifth grader. figure it out. but training a neural network is really difficult. and without training, your network is useless. so learn neural network training

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question