# normprod

Normalized dot product weight function

## Syntax

```Z = normprod(W,P,FP) dim = normprod('size',S,R,FP) dw = normprod('dz_dw',W,P,Z,FP) ```

## Description

`normprod` is a weight function. Weight functions apply weights to an input to get weighted inputs.

`Z = normprod(W,P,FP)` takes these inputs,

 `W` `S`-by-`R` weight matrix `P` `R`-by-`Q` matrix of `Q` input (column) vectors `FP` Row cell array of function parameters (optional, ignored)

and returns the `S`-by-`Q` matrix of normalized dot products.

`dim = normprod('size',S,R,FP)` takes the layer dimension `S`, input dimension `R`, and function parameters, and returns the weight size [`S`-by-`R`].

`dw = normprod('dz_dw',W,P,Z,FP)` returns the derivative of `Z` with respect to `W`.

## Examples

Here you define a random weight matrix `W` and input vector `P` and calculate the corresponding weighted input `Z`.

```W = rand(4,3); P = rand(3,1); Z = normprod(W,P) ```

## Network Use

You can create a standard network that uses `normprod` by calling `newgrnn`.

To change a network so an input weight uses `normprod`, set `net.inputWeights{i,j}.weightFcn` to `'normprod'`. For a layer weight, set `net.layerWeights{i,j}.weightFcn` to `'normprod'`.

In either case, call `sim` to simulate the network with `normprod`. See `newgrnn` for simulation examples.

## Algorithms

`normprod` returns the dot product normalized by the sum of the input vector elements.

```z = w*p/sum(p) ```