Android面试超级攻略全面破技术疑难及面试痛点
测试集说明
- 测试集分为两个文件夹:测试集初赛、测试集决赛,初赛和决赛的文件夹组织方式分歧;
- 初赛和决赛文件夹各包括80个时段的数据,每个时段1小时数据(30S分辨率,时间以秒数表达),春夏秋冬各20个时段,初赛编号1-20,决赛编号21-40;即初赛的时段编号为春_01-冬_20共80个;决赛的时段编号为春_21-冬_40共80个;
- 各机组的数据文件按照 /测试集_**/[风场]/[机组]/[时段].csv 的方式存储;
- 气候数据存储在 /测试集_**/[风场]/ 文件夹下,共80个时段风场所在地的风速风向数据,每个时段提供过去12小时和未来1小时的风速微风向数据。时段编码同上,时间编码为-11~2,其中0~1这个小时正好对应的是机舱的1小时数据。
- 运用飞桨框架构建的最终模型构造的代码如下:
class network(nn.Layer): def __init__(self, name_scope='baseline'): super(network, self).__init__(name_scope) name_scope = self.full_name() self.lstm1 = paddle.nn.LSTM(128, 128, direction = 'bidirectional', dropout=0.0) self.lstm2 = paddle.nn.LSTM(25, 128, direction = 'bidirectional', dropout=0.0) self.embedding_layer1= paddle.nn.Embedding(100, 4) self.embedding_layer2 = paddle.nn.Embedding(100, 16) self.mlp1 = paddle.nn.Linear(29, 128) self.mlp_bn1 = paddle.nn.BatchNorm(120) self.bn2 = paddle.nn.BatchNorm(14) self.mlp2 = paddle.nn.Linear(1536, 256) self.mlp_bn2 = paddle.nn.BatchNorm(256) self.lstm_out1 = paddle.nn.LSTM(256, 256, direction = 'bidirectional', dropout=0.0) self.lstm_out2 = paddle.nn.LSTM(512, 128, direction = 'bidirectional', dropout=0.0) self.lstm_out3 = paddle.nn.LSTM(256, 64, direction = 'bidirectional', dropout=0.0) self.lstm_out4 = paddle.nn.LSTM(128, 64, direction = 'bidirectional', dropout=0.0) self.output = paddle.nn.Linear(128, 2, ) self.sigmoid = paddle.nn.Sigmoid() # 网络的前向计算函数 def forward(self, input1, input2): embedded1 = self.embedding_layer1(paddle.cast(input1[:,:,0], dtype='int64')) embedded2 = self.embedding_layer2(paddle.cast(input1[:,:,1]+input1[:,:,0] # * 30 , dtype='int64')) x1 = paddle.concat([ embedded1, embedded2, input1[:,:,2:], input1[:,:,-2:-1] * paddle.sin(np.pi * 2 *input1[:,:,-1:]), input1[:,:,-2:-1] * paddle.cos(np.pi * 2 *input1[:,:,-1:]), paddle.sin(np.pi * 2 *input1[:,:,-1:]), paddle.cos(np.pi * 2 *input1[:,:,-1:]), ], axis=-1) # 4+16+5+2+2 = 29 x1 = self.mlp1(x1) x1 = self.mlp_bn1(x1) x1 = paddle.nn.ReLU()(x1) x2 = paddle.concat([ embedded1[:,:14], embedded2[:,:14], input2[:,:,:-1], input2[:,:,-2:-1] * paddle.sin(np.pi * 2 * input2[:,:,-1:]/360.), input2[:,:,-2:-1] * paddle.cos(np.pi * 2 * input2[:,:,-1:]/360.), paddle.sin(np.pi * 2 * input2[:,:,-1:]/360.), paddle.cos(np.pi * 2 * input2[:,:,-1:]/360.), ], axis=-1) # 4+16+1+2+2 = 25 x2 = self.bn2(x2) x1_lstm_out, (hidden, _) = self.lstm1(x1) x1 = paddle.concat([ hidden[-2, :, :], hidden[-1, :, :], paddle.max(x1_lstm_out, axis=1), paddle.mean(x1_lstm_out, axis=1) ], axis=-1) x2_lstm_out, (hidden, _) = self.lstm2(x2) x2 = paddle.concat([ hidden[-2, :, :], hidden[-1, :, :], paddle.max(x2_lstm_out, axis=1), paddle.mean(x2_lstm_out, axis=1) ], axis=-1) x = paddle.concat([x1, x2], axis=-1) x = self.mlp2(x) x = self.mlp_bn2(x) x = paddle.nn.ReLU()(x) # decoder x = paddle.stack([x]*20, axis=1) x = self.lstm_out1(x)[0] x = self.lstm_out2(x)[0] x = self.lstm_out3(x)[0] x = self.lstm_out4(x)[0] x = self.output(x) output = self.sigmoid(x)*2-1 output = paddle.cast(output, dtype='float32') return output 复制代码
点击下载