Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
69ca640d
Unverified
Commit
69ca640d
authored
Feb 14, 2024
by
Huazhong Ji
Committed by
GitHub
Feb 14, 2024
Browse files
Set the dataset format used by `test_trainer` to float32 (#28920)
Co-authored-by:
unit_test
<
test@unit.com
>
parent
7252e8d9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
tests/trainer/test_trainer.py
tests/trainer/test_trainer.py
+3
-3
No files found.
tests/trainer/test_trainer.py
View file @
69ca640d
...
@@ -176,8 +176,8 @@ class DynamicShapesDataset:
...
@@ -176,8 +176,8 @@ class DynamicShapesDataset:
np
.
random
.
seed
(
seed
)
np
.
random
.
seed
(
seed
)
sizes
=
np
.
random
.
randint
(
1
,
20
,
(
length
//
batch_size
,))
sizes
=
np
.
random
.
randint
(
1
,
20
,
(
length
//
batch_size
,))
# For easy batching, we make every batch_size consecutive samples the same size.
# For easy batching, we make every batch_size consecutive samples the same size.
self
.
xs
=
[
np
.
random
.
normal
(
size
=
(
s
,))
for
s
in
sizes
.
repeat
(
batch_size
)]
self
.
xs
=
[
np
.
random
.
normal
(
size
=
(
s
,))
.
astype
(
np
.
float32
)
for
s
in
sizes
.
repeat
(
batch_size
)]
self
.
ys
=
[
np
.
random
.
normal
(
size
=
(
s
,))
for
s
in
sizes
.
repeat
(
batch_size
)]
self
.
ys
=
[
np
.
random
.
normal
(
size
=
(
s
,))
.
astype
(
np
.
float32
)
for
s
in
sizes
.
repeat
(
batch_size
)]
def
__len__
(
self
):
def
__len__
(
self
):
return
self
.
length
return
self
.
length
...
@@ -547,7 +547,7 @@ class TrainerIntegrationPrerunTest(TestCasePlus, TrainerIntegrationCommon):
...
@@ -547,7 +547,7 @@ class TrainerIntegrationPrerunTest(TestCasePlus, TrainerIntegrationCommon):
np
.
random
.
seed
(
42
)
np
.
random
.
seed
(
42
)
x
=
np
.
random
.
normal
(
size
=
(
64
,)).
astype
(
np
.
float32
)
x
=
np
.
random
.
normal
(
size
=
(
64
,)).
astype
(
np
.
float32
)
y
=
2.0
*
x
+
3.0
+
np
.
random
.
normal
(
scale
=
0.1
,
size
=
(
64
,))
y
=
2.0
*
x
+
3.0
+
np
.
random
.
normal
(
scale
=
0.1
,
size
=
(
64
,))
.
astype
(
np
.
float32
)
train_dataset
=
datasets
.
Dataset
.
from_dict
({
"input_x"
:
x
,
"label"
:
y
})
train_dataset
=
datasets
.
Dataset
.
from_dict
({
"input_x"
:
x
,
"label"
:
y
})
# Base training. Should have the same results as test_reproducible_training
# Base training. Should have the same results as test_reproducible_training
...
...
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