You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could someone be so kind to have a look if I make my net wrong or something?
I should say that my network DOES learn, but LSTM part does not!
Could really use a second pair of eyes, thanks!
my input are sequences of actions of the shape: [sequenceLength, obsSize]
public class PPOCriticNet1D : PPOCriticNet
{
private readonly ModuleList<Module<Tensor, Tensor>> fcModules = new();
private readonly Module<Tensor, Tensor> head;
private readonly LSTM lstmLayer;
private readonly int hiddenSize;
private readonly bool useRnn;
public PPOCriticNet1D(string name, long inputs, int width, int depth = 3, bool useRNN = false) : base(name)
{
// Ensure depth is at least 1.
if (depth < 1) throw new ArgumentOutOfRangeException("Depth must be 1 or greater.");
this.useRnn = useRNN;
this.hiddenSize = width; // Modify as per your architecture choice
fcModules.Add(Linear(inputs, width));
for (int i = 1; i < depth; i++)
{
fcModules.Add(Linear(width, width));
}
if (useRnn)
{
lstmLayer = nn.LSTM(width, hiddenSize, 2, batchFirst: true);
width = hiddenSize;
}
// Final layer to produce the value estimate.
head = Linear(width, 1);
RegisterComponents();
}
public override Tensor forward(Tensor x)
{
// Adjust for a single input.
if (x.dim() == 1)
{
x = x.unsqueeze(0);
}
x = functional.tanh(fcModules.First().forward(x));
if (useRnn)
{
x = x.unsqueeze(0);
x = lstmLayer.forward(x).Item1;
x = x.squeeze(0);
}
foreach (var module in fcModules.Skip(1))
{
x = functional.tanh(module.forward(x));
}
var result = head.forward(x);
return result;
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
foreach (var module in fcModules)
{
module.Dispose();
}
lstmLayer?.Dispose();
head.Dispose();
}
base.Dispose(disposing);
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Could someone be so kind to have a look if I make my net wrong or something?
I should say that my network DOES learn, but LSTM part does not!
Could really use a second pair of eyes, thanks!
my input are sequences of actions of the shape: [sequenceLength, obsSize]
Beta Was this translation helpful? Give feedback.
All reactions