Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
417 views
in Technique[技术] by (71.8m points)

python - ValueError: shapes not aligned, but I don't understand the error

Hi I'm watching a youtube machine learning lecture and I'm copying the code that is written there. I get an error message on this bit of code:

def forward_propagate(self, inputs):
    activations = inputs
    for weight in self.weights:
        #calculate net inputs
        net_inputs = np.dot(activations, weight)

"activations" is an array with dimensions (3,) as shown when I type in activations.shape in ipython

"weight" is an array with dimensions (3,3)

This is my error:

Traceback (most recent call last):
  File "lesson6.py", line 51, in <module>
    outputs = mlp.forward_propagate(inputs)
  File "lesson6.py", line 29, in forward_propagate
    net_inputs = np.dot(activations, weight)
  File "<__array_function__ internals>", line 5, in dot
ValueError: shapes (3,) and (5,2) not aligned: 3 (dim 0) != 5 (dim 0)

What is being referred to in the (5,2)? I put an import pdb pdb.set_trace() right before the error and the array shapes that are passed in are (3,) and (3,3)?

question from:https://stackoverflow.com/questions/65545661/valueerror-shapes-not-aligned-but-i-dont-understand-the-error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...