(self, embeddings, labels)
| 12 | self.mse_loss = fluid.dygraph.MSELoss(reduction='sum') |
| 13 | |
| 14 | def specific_method(self, embeddings, labels): |
| 15 | x_train, x_query, y_train, y_query = self.split_train_query(embeddings, labels) |
| 16 | protos = fluid.layers.reduce_mean(x_train, dim=1) # [5,64,21,21] |
| 17 | query_embs = fluid.layers.reshape(x_query, [self.args.n_way*self.args.n_query, x_query.shape[-3],x_query.shape[-2], x_query.shape[-1]]) #[75,64,21,21] |
| 18 | # concatenate |
| 19 | protos_exp = fluid.layers.expand(fluid.layers.unsqueeze(protos,[0]), [query_embs.shape[0],1,1,1,1]) |
| 20 | query_embs_exp = fluid.layers.expand(fluid.layers.unsqueeze(query_embs,[1]), [1,protos.shape[0],1,1,1]) |
| 21 | concat_pairs = fluid.layers.concat(input=[protos_exp, query_embs_exp], axis=2) |
| 22 | concat_paris_all = fluid.layers.reshape(concat_pairs, [concat_pairs.shape[0]*concat_pairs.shape[1],concat_pairs.shape[2],concat_pairs.shape[3],concat_pairs.shape[4]]) # [75*5, 128,21,21] |
| 23 | |
| 24 | relation_scores = fluid.layers.reshape(self.reslation_module(concat_paris_all), [concat_pairs.shape[0], concat_pairs.shape[1]]) # [75,5] |
| 25 | return relation_scores, y_query |
| 26 | |
| 27 | def loss(self, x, y): |
| 28 | relation_scores, query_labels = self.forward(x, y) |
nothing calls this directly
no test coverage detected