Skip to content

Chapter 5: weight_deltas calculation in case of multiple inputs and multiple outputs #23

Open
@dimchansky

Description

@dimchansky

weight_deltas are calculated in this way:

[ [input[0] * delta[0], input[0] * delta[1], input[0] * delta[2]],
  [input[1] * delta[0], input[1] * delta[1], input[1] * delta[2]],
  [input[2] * delta[0], input[2] * delta[1], input[2] * delta[2]] ]

but should be transposed:

[ [input[0] * delta[0], input[1] * delta[0], input[2] * delta[0]],
  [input[0] * delta[1], input[1] * delta[1], input[2] * delta[1]],
  [input[0] * delta[2], input[1] * delta[2], input[2] * delta[2]] ]

otherwise weights are updated incorrectly.

Current code:

import numpy as np
def outer_prod(a, b):
    
    # just a matrix of zeros
    out = np.zeros((len(a), len(b)))

    for i in range(len(a)):
        for j in range(len(b)):
            out[i][j] = a[i] * b[j]
    return out

weight_deltas = outer_prod(input,delta)

PR should fix the issue: #22

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions