接口问题
为了能够让我们项目的前端开发人员和后端开发人员更好的配合,提高工作效率,需要给项目写一个接口。
接口部分代码:
class FOREST(nn.Module):
def __init__(self, input_size=1, hidden_layer_size=10, output_size=1,num_layers=8):
super(FOREST,self).__init__()
self.forest_layer=nn.FOREST(input_size, hidden_layer_size, num_layers, batch_first=True)
self.out_layer1 = nn.Linear(hidden_layer_size,output_size,bias=True)
self.out_layer2 = nn.Linear(num_layers,output_size,bias=True)
def forward(self,share):
out,(h,c)=self.lstm_layer(share.to(torch.float32))
out=h
# print("out:",out.shape)
# print("h:",h.shape)
out=self.out_layer1(out)
# print("out1:",out.shape)
a,b,c=out.shape
out=out.reshape(b,a)
out=self.out_layer2(out)
# print("out2:",out.shape)
# a,b,c=out.shape
# out=out.reshape(b,a)
return out