Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pinyin2hanzi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邵子睿(21软)
pinyin2hanzi
Commits
1c06d13f
You need to sign in or sign up before continuing.
Commit
1c06d13f
authored
Feb 16, 2022
by
szr712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改output max的错误
parent
a0b3ed3a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
translate_file2.py
translate_file2.py
+5
-1
No files found.
translate_file2.py
View file @
1c06d13f
...
...
@@ -72,6 +72,8 @@ def get_result(src, model, SRC, TRG, opt):
if
opt
.
tone_filter
==
True
:
output_min
,
_
=
output
.
min
(
dim
=-
1
)
output_min
=
output_min
.
min
()
output_max
,
_
=
output
.
max
(
dim
=-
1
)
output_max
=
output_max
.
max
()
vals
,
indices
=
output
.
topk
(
k
=
10
,
dim
=-
1
,
largest
=
True
,
sorted
=
True
)
result
=
[]
for
x
,
index
in
enumerate
(
src
[
0
][:]):
...
...
@@ -94,6 +96,7 @@ def get_result(src, model, SRC, TRG, opt):
output
[
0
,
x
,
indices
[
0
][
x
][
i
]]
=
output_min
if
not
flag
:
result
.
append
(
TRG
.
vocab
.
itos
[
indices
[
0
][
x
][
0
]])
output
[
0
,
x
,
indices
[
0
][
x
][
0
]]
=
output_max
# 查看之前的声母
else
:
result
=
result
[:
-
1
]
...
...
@@ -112,9 +115,10 @@ def get_result(src, model, SRC, TRG, opt):
# if flag:
# break
if
not
flag
:
output
[
0
,
x
,
indices
[
0
][
x
][
i
]]
=
output_min
output
[
0
,
x
-
1
,
indices
[
0
][
x
-
1
][
i
]]
=
output_min
if
not
flag
:
result
.
append
(
TRG
.
vocab
.
itos
[
indices
[
0
][
x
-
1
][
0
]])
output
[
0
,
x
,
indices
[
0
][
x
-
1
][
0
]]
=
output_max
result
.
append
(
TRG
.
vocab
.
itos
[
indices
[
0
][
x
][
0
]])
else
:
result
.
append
(
TRG
.
vocab
.
itos
[
indices
[
0
][
x
][
0
]])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment