Message Boards Message Boards

1
|
3760 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Getting predictions of specific values from NetChain

Posted 2 years ago

Hi,

How do I get the Gm values for the specific values of tm={ 200, 210, 215,235} ?

Thank you so much.

tm = {0, 2, 4, 6, 8, 10, 12, 14, 16, 19, 22, 27, 32, 42, 52, 62, 72, 
   82, 92, 102, 122, 142, 162, 182};

Gm = {92, 350, 287, 251, 240, 216, 211, 205, 196, 192, 172, 163, 142, 
   124, 105, 92, 84, 77, 82, 81, 82, 82, 85, 90};

dataxy = Transpose[{tm, Gm}];

p0 = ListPlot[dataxy, PlotStyle -> {Red, PointSize[0.01]}, 
   Frame -> True];

data = {0 -> 92, 2 -> 350, 4 -> 287, 6 -> 251, 8 -> 240, 10 -> 216, 
   12 -> 211, 14 -> 205, 16 -> 196, 19 -> 192, 22 -> 172, 27 -> 163, 
   32 -> 142, 42 -> 124, 52 -> 105, 62 -> 92, 72 -> 84, 82 -> 77, 
   92 -> 82, 102 -> 81, 122 -> 82, 142 -> 82, 162 -> 85, 182 -> 90};

dropoutNet01 = NetChain[{150, DropoutLayer[0.1], Tanh, 150, Tanh, 1}];

results5 = NetTrain[dropoutNet01, data, All];

result = results5["TrainedNet"];

Show[{p0, 
  Plot[result[x], {x, 0, 182}, PlotStyle -> {Blue}, 
   PlotRange -> {0, 360}]}]

enter image description here

POSTED BY: Alex Teymouri
2 Replies

I am not sure I understand your problem correctly. If what you are asking is how to get the prediction for specific values it is just

result[{200, 210, 215, 235}]
(* {82.839, 82.8391, 82.8392, 82.8393} *)

By the way, there are ways to generate data programmatically

data == Rule @@@ dataxy == Thread[Rule[tm, Gm]]
(* True *)
Posted 2 years ago

Thank you Giulio! This was really helpful.

Regards,

POSTED BY: Alex Teymouri
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