Message Boards Message Boards

0
|
2580 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Use `ReplaceAll` to modify a network layer ?

Posted 3 years ago

I was reading a paper mentioning the use of a neural network model available in the Wolfram neural repository. The authors explained that they modified the model to use the average function in the pooling layers instead of the max function.

I naïvely thought I could do the same by just applying the rule Max -> Mean to all pooling layers to get the same result, but I didn't succeed.

Here is the simplest possible example I could come up with to show you what I mean :

LinearLayer[2] /. 2 -> 3

Why doesn't this instruction return a LinearLayer with three outputs instead of two ? I feel like I'm missing something obvious but I don't see it :-/

PS. It seems that what I was initially looking for is NetReplacePart.

POSTED BY: Lucien Grondin
2 Replies
Posted 3 years ago

Hi Lucien

The reason is that LinearLayer[2] is evaluated before the Replace. One workaround

Unevaluated[LinearLayer[2]] /. 2 -> 3

WL evaluation is described here.

POSTED BY: Rohit Namjoshi

But isn't there necessarily a "2" somewhere in the evaluated form of LinearLayer[2] ?

I mean if I define say f[] := foo then f[] /. foo -> bar does return bar.

POSTED BY: Lucien Grondin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract