@@ -1,15 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project version="4"> | |||||
<component name="PublishConfigData" autoUpload="Always" serverName="zyfeng@10.40.40.86:22"> | |||||
<serverData> | |||||
<paths name="zyfeng@10.40.40.86:22"> | |||||
<serverdata> | |||||
<mappings> | |||||
<mapping deploy="/home/zyfeng/Desktop/fastNLP" local="$PROJECT_DIR$" /> | |||||
</mappings> | |||||
</serverdata> | |||||
</paths> | |||||
</serverData> | |||||
<option name="myAutoUpload" value="ALWAYS" /> | |||||
</component> | |||||
</project> |
@@ -1,14 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<module type="PYTHON_MODULE" version="4"> | |||||
<component name="NewModuleRootManager"> | |||||
<content url="file://$MODULE_DIR$" /> | |||||
<orderEntry type="jdk" jdkName="Remote Python 3.6.6 (sftp://zyfeng@10.40.40.86:22/home/zyfeng/miniconda3/envs/fastnlp/bin/python3.6)" jdkType="Python SDK" /> | |||||
<orderEntry type="sourceFolder" forTests="false" /> | |||||
</component> | |||||
<component name="PyDocumentationSettings"> | |||||
<option name="renderExternalDocumentation" value="true" /> | |||||
</component> | |||||
<component name="TestRunnerService"> | |||||
<option name="PROJECT_TEST_RUNNER" value="Unittests" /> | |||||
</component> | |||||
</module> |
@@ -1,16 +0,0 @@ | |||||
<component name="InspectionProjectProfileManager"> | |||||
<profile version="1.0"> | |||||
<option name="myName" value="Project Default" /> | |||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true"> | |||||
<option name="ignoredPackages"> | |||||
<value> | |||||
<list size="3"> | |||||
<item index="0" class="java.lang.String" itemvalue="torch" /> | |||||
<item index="1" class="java.lang.String" itemvalue="numpy" /> | |||||
<item index="2" class="java.lang.String" itemvalue="torchvision" /> | |||||
</list> | |||||
</value> | |||||
</option> | |||||
</inspection_tool> | |||||
</profile> | |||||
</component> |
@@ -1,7 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project version="4"> | |||||
<component name="JavaScriptSettings"> | |||||
<option name="languageLevel" value="ES6" /> | |||||
</component> | |||||
<component name="ProjectRootManager" version="2" project-jdk-name="Remote Python 3.6.6 (sftp://zyfeng@10.40.40.86:22/home/zyfeng/miniconda3/envs/fastnlp/bin/python3.6)" project-jdk-type="Python SDK" /> | |||||
</project> |
@@ -1,8 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project version="4"> | |||||
<component name="ProjectModuleManager"> | |||||
<modules> | |||||
<module fileurl="file://$PROJECT_DIR$/.idea/fastNLP.iml" filepath="$PROJECT_DIR$/.idea/fastNLP.iml" /> | |||||
</modules> | |||||
</component> | |||||
</project> |
@@ -1,7 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project version="4"> | |||||
<component name="PySciProjectComponent"> | |||||
<option name="PY_SCI_VIEW" value="true" /> | |||||
<option name="PY_SCI_VIEW_SUGGESTED" value="true" /> | |||||
</component> | |||||
</project> |
@@ -1,6 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project version="4"> | |||||
<component name="VcsDirectoryMappings"> | |||||
<mapping directory="$PROJECT_DIR$" vcs="Git" /> | |||||
</component> | |||||
</project> |
@@ -158,8 +158,8 @@ class POSTester(BaseTester): | |||||
def evaluate(self, predict, truth): | def evaluate(self, predict, truth): | ||||
truth = torch.Tensor(truth) | truth = torch.Tensor(truth) | ||||
loss, prediction = self.model.loss(predict, truth, self.mask, self.batch_size, self.max_len) | loss, prediction = self.model.loss(predict, truth, self.mask, self.batch_size, self.max_len) | ||||
results = torch.Tensor(prediction[0][0]).view((-1, )) | |||||
accuracy = float(torch.sum(results == truth.view((-1, )))) / results.shape[0] | |||||
results = torch.Tensor(prediction[0][0]).view((-1,)) | |||||
accuracy = float(torch.sum(results == truth.view((-1,)))) / results.shape[0] | |||||
return [loss.data, accuracy] | return [loss.data, accuracy] | ||||
def matrices(self): | def matrices(self): | ||||
@@ -174,5 +174,3 @@ class POSTester(BaseTester): | |||||
""" | """ | ||||
loss, accuracy = self.matrices() | loss, accuracy = self.matrices() | ||||
return "dev loss={:.2f}, accuracy={:.2f}".format(loss, accuracy) | return "dev loss={:.2f}, accuracy={:.2f}".format(loss, accuracy) | ||||
@@ -2,16 +2,17 @@ | |||||
This is borrowed from FudanParser. Not stable. Do not use !!! | This is borrowed from FudanParser. Not stable. Do not use !!! | ||||
""" | """ | ||||
import numpy | |||||
import numpy as np | import numpy as np | ||||
import torch | |||||
import torch.nn as nn | import torch.nn as nn | ||||
import torch.nn.functional as F | import torch.nn.functional as F | ||||
from torch.nn import Parameter | |||||
from .utils import orthogonal | |||||
import torch | |||||
import torch.utils.data | import torch.utils.data | ||||
import numpy | |||||
from torch.autograd import Function, Variable | |||||
from torch import optim | from torch import optim | ||||
from torch.autograd import Function, Variable | |||||
from torch.nn import Parameter | |||||
from .utils import orthogonal | |||||
class GroupNorm(nn.Module): | class GroupNorm(nn.Module): | ||||
@@ -53,7 +53,7 @@ if __name__ == "__main__": | |||||
test_args = ConfigSection() | test_args = ConfigSection() | ||||
ConfigLoader("config.cfg", "").load_config("./data_for_tests/config", {"POS_test": test_args}) | ConfigLoader("config.cfg", "").load_config("./data_for_tests/config", {"POS_test": test_args}) | ||||
#test_args = {"save_output": True, "validate_in_training": False, "save_dev_input": False, | |||||
# test_args = {"save_output": True, "validate_in_training": False, "save_dev_input": False, | |||||
# "save_loss": True, "batch_size": 1, "pickle_path": pickle_path} | # "save_loss": True, "batch_size": 1, "pickle_path": pickle_path} | ||||
tester = POSTester(test_args) | tester = POSTester(test_args) | ||||
tester.test(model) | tester.test(model) | ||||