Download model/head/node_centric_head.py from ltg/ssa-perin: direct link, hf CLI and curl.
- Browser
- Download file 811 Bytes
-
https://huggingface.co/ltg/ssa-perin/resolve/main/model/head/node_centric_head.py
- Command line
-
hf download hf://ltg/ssa-perin/model/head/node_centric_head.py
-
curl -L -o node_centric_head.py https://huggingface.co/ltg/ssa-perin/resolve/main/model/head/node_centric_head.py
811 Bytes
| #!/usr/bin/env python3 | |
| # coding=utf-8 | |
| import torch | |
| from model.head.abstract_head import AbstractHead | |
| from data.parser.to_mrp.node_centric_parser import NodeCentricParser | |
| from utility.cross_entropy import binary_cross_entropy | |
| class NodeCentricHead(AbstractHead): | |
| def __init__(self, dataset, args, initialize): | |
| config = { | |
| "label": True, | |
| "edge presence": True, | |
| "edge label": False, | |
| "anchor": True, | |
| "source_anchor": False, | |
| "target_anchor": False | |
| } | |
| super(NodeCentricHead, self).__init__(dataset, args, config, initialize) | |
| self.source_id = dataset.label_field.vocab.stoi["Source"] + 1 | |
| self.target_id = dataset.label_field.vocab.stoi["Target"] + 1 | |
| self.parser = NodeCentricParser(dataset) | |