FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docker-python/tests/test_fastai.py at master · AI-For-Rural/docker-python · GitHub
AI-For-Rural
/
docker-python
Public
forked from
Kaggle/docker-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
docker-python
/
tests
/
test_fastai.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (32 loc) · 1.21 KB
Breadcrumbs
docker-python
/
tests
/
test_fastai.py
Copy path
File metadata and controls
42 lines (32 loc) · 1.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import
unittest
import
fastai
import
pandas
as
pd
import
torch
from
fastai
.
tabular
import
*
from
fastai
.
core
import
partition
from
fastai
.
torch_core
import
tensor
class
TestFastAI
(
unittest
.
TestCase
):
def
test_partition
(
self
):
result
=
partition
([
1
,
2
,
3
,
4
,
5
],
2
)
self
.
assertEqual
(
3
,
len
(
result
))
def
test_has_version
(
self
):
self
.
assertGreater
(
len
(
fastai
.
__version__
),
1
)
# based on https://github.com/fastai/fastai/blob/master/tests/test_torch_core.py#L17
def
test_torch_tensor
(
self
):
a
=
tensor
([
1
,
2
,
3
])
b
=
torch
.
tensor
([
1
,
2
,
3
])
self
.
assertTrue
(
torch
.
all
(
a
==
b
))
def
test_tabular
(
self
):
df
=
pd
.
read_csv
(
"/input/tests/data/train.csv"
)
procs
=
[
FillMissing
,
Categorify
,
Normalize
]
valid_idx
=
range
(
len
(
df
)
-
5
,
len
(
df
))
dep_var
=
"label"
cont_names
=
[]
for
i
in
range
(
784
):
cont_names
.
append
(
"pixel"
+
str
(
i
))
data
=
(
TabularList
.
from_df
(
df
,
path
=
""
,
cont_names
=
cont_names
,
cat_names
=
[],
procs
=
procs
)
.
split_by_idx
(
valid_idx
)
.
label_from_df
(
cols
=
dep_var
)
.
databunch
())
learn
=
tabular_learner
(
data
,
layers
=
[
200
,
100
])
learn
.
fit
(
epochs
=
1
)
Back
|
FazBrowse Home
|
New Git URL