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
OpenDAS
dgl
Commits
15ace31a
Unverified
Commit
15ace31a
authored
Apr 15, 2024
by
Songqing Zhang
Committed by
GitHub
Apr 15, 2024
Browse files
[Misc] Using the aliases of builtin types like np.int is deprecated (#7300)
parent
2ff3006c
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
20 deletions
+20
-20
examples/pytorch/ggnn/train_gc.py
examples/pytorch/ggnn/train_gc.py
+2
-2
examples/pytorch/hilander/utils/evaluate.py
examples/pytorch/hilander/utils/evaluate.py
+1
-1
examples/pytorch/mvgrl/graph/dataset.py
examples/pytorch/mvgrl/graph/dataset.py
+2
-2
examples/pytorch/ogb/deepwalk/reading_data.py
examples/pytorch/ogb/deepwalk/reading_data.py
+2
-2
examples/pytorch/ogb/line/reading_data.py
examples/pytorch/ogb/line/reading_data.py
+2
-2
examples/pytorch/pointcloud/pct/ShapeNet.py
examples/pytorch/pointcloud/pct/ShapeNet.py
+2
-2
examples/pytorch/pointcloud/point_transformer/ShapeNet.py
examples/pytorch/pointcloud/point_transformer/ShapeNet.py
+4
-4
examples/pytorch/pointcloud/pointnet/ShapeNet.py
examples/pytorch/pointcloud/pointnet/ShapeNet.py
+4
-4
examples/pytorch/rrn/ckpt/rrn-sudoku.pkl
examples/pytorch/rrn/ckpt/rrn-sudoku.pkl
+0
-0
examples/pytorch/rrn/sudoku_solver.py
examples/pytorch/rrn/sudoku_solver.py
+1
-1
No files found.
examples/pytorch/ggnn/train_gc.py
View file @
15ace31a
...
@@ -60,7 +60,7 @@ def main(args):
...
@@ -60,7 +60,7 @@ def main(args):
labels
=
labels
.
data
.
numpy
().
tolist
()
labels
=
labels
.
data
.
numpy
().
tolist
()
dev_preds
+=
preds
dev_preds
+=
preds
dev_labels
+=
labels
dev_labels
+=
labels
acc
=
np
.
equal
(
dev_labels
,
dev_preds
).
astype
(
np
.
float
).
tolist
()
acc
=
np
.
equal
(
dev_labels
,
dev_preds
).
astype
(
float
).
tolist
()
acc
=
sum
(
acc
)
/
len
(
acc
)
acc
=
sum
(
acc
)
/
len
(
acc
)
print
(
f
"Epoch
{
epoch
}
, Dev acc
{
acc
}
"
)
print
(
f
"Epoch
{
epoch
}
, Dev acc
{
acc
}
"
)
...
@@ -80,7 +80,7 @@ def main(args):
...
@@ -80,7 +80,7 @@ def main(args):
labels
=
labels
.
data
.
numpy
().
tolist
()
labels
=
labels
.
data
.
numpy
().
tolist
()
test_preds
+=
preds
test_preds
+=
preds
test_labels
+=
labels
test_labels
+=
labels
acc
=
np
.
equal
(
test_labels
,
test_preds
).
astype
(
np
.
float
).
tolist
()
acc
=
np
.
equal
(
test_labels
,
test_preds
).
astype
(
float
).
tolist
()
acc
=
sum
(
acc
)
/
len
(
acc
)
acc
=
sum
(
acc
)
/
len
(
acc
)
test_acc_list
.
append
(
acc
)
test_acc_list
.
append
(
acc
)
...
...
examples/pytorch/hilander/utils/evaluate.py
View file @
15ace31a
...
@@ -40,7 +40,7 @@ def evaluate(gt_labels, pred_labels, metric="pairwise"):
...
@@ -40,7 +40,7 @@ def evaluate(gt_labels, pred_labels, metric="pairwise"):
"evaluate with {}{}{}"
.
format
(
TextColors
.
FATAL
,
metric
,
TextColors
.
ENDC
)
"evaluate with {}{}{}"
.
format
(
TextColors
.
FATAL
,
metric
,
TextColors
.
ENDC
)
):
):
result
=
metric_func
(
gt_labels
,
pred_labels
)
result
=
metric_func
(
gt_labels
,
pred_labels
)
if
isinstance
(
result
,
np
.
float
):
if
isinstance
(
result
,
float
):
print
(
print
(
"{}{}: {:.4f}{}"
.
format
(
"{}{}: {:.4f}{}"
.
format
(
TextColors
.
OKGREEN
,
metric
,
result
,
TextColors
.
ENDC
TextColors
.
OKGREEN
,
metric
,
result
,
TextColors
.
ENDC
...
...
examples/pytorch/mvgrl/graph/dataset.py
View file @
15ace31a
...
@@ -68,7 +68,7 @@ def process(dataset):
...
@@ -68,7 +68,7 @@ def process(dataset):
for
attr
in
re
.
split
(
"[,\s]+"
,
line
.
strip
(
"\s
\n
"
))
for
attr
in
re
.
split
(
"[,\s]+"
,
line
.
strip
(
"\s
\n
"
))
if
attr
if
attr
],
],
dtype
=
np
.
float
,
dtype
=
float
,
)
)
)
)
else
:
else
:
...
@@ -130,7 +130,7 @@ def process(dataset):
...
@@ -130,7 +130,7 @@ def process(dataset):
f
[
graph
.
degree
[
u
[
0
]]]
=
1.0
f
[
graph
.
degree
[
u
[
0
]]]
=
1.0
if
"label"
in
u
[
1
]:
if
"label"
in
u
[
1
]:
f
=
np
.
concatenate
(
f
=
np
.
concatenate
(
(
np
.
array
(
u
[
1
][
"label"
],
dtype
=
np
.
float
),
f
)
(
np
.
array
(
u
[
1
][
"label"
],
dtype
=
float
),
f
)
)
)
graph
.
nodes
[
u
[
0
]][
"feat"
]
=
f
graph
.
nodes
[
u
[
0
]][
"feat"
]
=
f
return
graphs
,
pprs
return
graphs
,
pprs
...
...
examples/pytorch/ogb/deepwalk/reading_data.py
View file @
15ace31a
...
@@ -213,13 +213,13 @@ class DeepwalkDataset:
...
@@ -213,13 +213,13 @@ class DeepwalkDataset:
node_degree
=
self
.
G
.
out_degrees
(
self
.
valid_seeds
).
numpy
()
node_degree
=
self
.
G
.
out_degrees
(
self
.
valid_seeds
).
numpy
()
node_degree
=
np
.
power
(
node_degree
,
0.75
)
node_degree
=
np
.
power
(
node_degree
,
0.75
)
node_degree
/=
np
.
sum
(
node_degree
)
node_degree
/=
np
.
sum
(
node_degree
)
node_degree
=
np
.
array
(
node_degree
*
1e8
,
dtype
=
np
.
int
)
node_degree
=
np
.
array
(
node_degree
*
1e8
,
dtype
=
int
)
self
.
neg_table
=
[]
self
.
neg_table
=
[]
for
idx
,
node
in
enumerate
(
self
.
valid_seeds
):
for
idx
,
node
in
enumerate
(
self
.
valid_seeds
):
self
.
neg_table
+=
[
node
]
*
node_degree
[
idx
]
self
.
neg_table
+=
[
node
]
*
node_degree
[
idx
]
self
.
neg_table_size
=
len
(
self
.
neg_table
)
self
.
neg_table_size
=
len
(
self
.
neg_table
)
self
.
neg_table
=
np
.
array
(
self
.
neg_table
,
dtype
=
np
.
long
)
self
.
neg_table
=
np
.
array
(
self
.
neg_table
,
dtype
=
int
)
del
node_degree
del
node_degree
def
create_sampler
(
self
,
i
):
def
create_sampler
(
self
,
i
):
...
...
examples/pytorch/ogb/line/reading_data.py
View file @
15ace31a
...
@@ -209,13 +209,13 @@ class LineDataset:
...
@@ -209,13 +209,13 @@ class LineDataset:
node_degree
=
self
.
G
.
out_degrees
(
self
.
valid_nodes
).
numpy
()
node_degree
=
self
.
G
.
out_degrees
(
self
.
valid_nodes
).
numpy
()
node_degree
=
np
.
power
(
node_degree
,
0.75
)
node_degree
=
np
.
power
(
node_degree
,
0.75
)
node_degree
/=
np
.
sum
(
node_degree
)
node_degree
/=
np
.
sum
(
node_degree
)
node_degree
=
np
.
array
(
node_degree
*
1e8
,
dtype
=
np
.
int
)
node_degree
=
np
.
array
(
node_degree
*
1e8
,
dtype
=
int
)
self
.
neg_table
=
[]
self
.
neg_table
=
[]
for
idx
,
node
in
enumerate
(
self
.
valid_nodes
):
for
idx
,
node
in
enumerate
(
self
.
valid_nodes
):
self
.
neg_table
+=
[
node
]
*
node_degree
[
idx
]
self
.
neg_table
+=
[
node
]
*
node_degree
[
idx
]
self
.
neg_table_size
=
len
(
self
.
neg_table
)
self
.
neg_table_size
=
len
(
self
.
neg_table
)
self
.
neg_table
=
np
.
array
(
self
.
neg_table
,
dtype
=
np
.
long
)
self
.
neg_table
=
np
.
array
(
self
.
neg_table
,
dtype
=
int
)
del
node_degree
del
node_degree
def
create_sampler
(
self
,
i
):
def
create_sampler
(
self
,
i
):
...
...
examples/pytorch/pointcloud/pct/ShapeNet.py
View file @
15ace31a
...
@@ -132,7 +132,7 @@ class ShapeNetDataset(Dataset):
...
@@ -132,7 +132,7 @@ class ShapeNetDataset(Dataset):
[
t
.
split
(
"
\n
"
)[
0
].
split
(
" "
)
for
t
in
f
.
readlines
()]
[
t
.
split
(
"
\n
"
)[
0
].
split
(
" "
)
for
t
in
f
.
readlines
()]
).
astype
(
np
.
float
)
).
astype
(
np
.
float
)
data_list
.
append
(
data
[:,
0
:
self
.
dim
])
data_list
.
append
(
data
[:,
0
:
self
.
dim
])
label_list
.
append
(
data
[:,
6
].
astype
(
np
.
int
))
label_list
.
append
(
data
[:,
6
].
astype
(
int
))
category_list
.
append
(
shapenet
.
synset_dict
[
fn
.
split
(
"/"
)[
-
2
]])
category_list
.
append
(
shapenet
.
synset_dict
[
fn
.
split
(
"/"
)[
-
2
]])
self
.
data
=
data_list
self
.
data
=
data_list
self
.
label
=
label_list
self
.
label
=
label_list
...
@@ -157,5 +157,5 @@ class ShapeNetDataset(Dataset):
...
@@ -157,5 +157,5 @@ class ShapeNetDataset(Dataset):
if
self
.
mode
==
"train"
:
if
self
.
mode
==
"train"
:
x
=
self
.
translate
(
x
,
size
=
self
.
dim
)
x
=
self
.
translate
(
x
,
size
=
self
.
dim
)
x
=
x
.
astype
(
np
.
float
)
x
=
x
.
astype
(
np
.
float
)
y
=
y
.
astype
(
np
.
int
)
y
=
y
.
astype
(
int
)
return
x
,
y
,
cat
return
x
,
y
,
cat
examples/pytorch/pointcloud/point_transformer/ShapeNet.py
View file @
15ace31a
...
@@ -130,9 +130,9 @@ class ShapeNetDataset(Dataset):
...
@@ -130,9 +130,9 @@ class ShapeNetDataset(Dataset):
with
open
(
fn
)
as
f
:
with
open
(
fn
)
as
f
:
data
=
np
.
array
(
data
=
np
.
array
(
[
t
.
split
(
"
\n
"
)[
0
].
split
(
" "
)
for
t
in
f
.
readlines
()]
[
t
.
split
(
"
\n
"
)[
0
].
split
(
" "
)
for
t
in
f
.
readlines
()]
).
astype
(
np
.
float
)
).
astype
(
float
)
data_list
.
append
(
data
[:,
0
:
self
.
dim
])
data_list
.
append
(
data
[:,
0
:
self
.
dim
])
label_list
.
append
(
data
[:,
6
].
astype
(
np
.
int
))
label_list
.
append
(
data
[:,
6
].
astype
(
int
))
category_list
.
append
(
shapenet
.
synset_dict
[
fn
.
split
(
"/"
)[
-
2
]])
category_list
.
append
(
shapenet
.
synset_dict
[
fn
.
split
(
"/"
)[
-
2
]])
self
.
data
=
data_list
self
.
data
=
data_list
self
.
label
=
label_list
self
.
label
=
label_list
...
@@ -156,6 +156,6 @@ class ShapeNetDataset(Dataset):
...
@@ -156,6 +156,6 @@ class ShapeNetDataset(Dataset):
cat
=
self
.
category
[
i
]
cat
=
self
.
category
[
i
]
if
self
.
mode
==
"train"
:
if
self
.
mode
==
"train"
:
x
=
self
.
translate
(
x
,
size
=
self
.
dim
)
x
=
self
.
translate
(
x
,
size
=
self
.
dim
)
x
=
x
.
astype
(
np
.
float
)
x
=
x
.
astype
(
float
)
y
=
y
.
astype
(
np
.
int
)
y
=
y
.
astype
(
int
)
return
x
,
y
,
cat
return
x
,
y
,
cat
examples/pytorch/pointcloud/pointnet/ShapeNet.py
View file @
15ace31a
...
@@ -130,9 +130,9 @@ class ShapeNetDataset(Dataset):
...
@@ -130,9 +130,9 @@ class ShapeNetDataset(Dataset):
with
open
(
fn
)
as
f
:
with
open
(
fn
)
as
f
:
data
=
np
.
array
(
data
=
np
.
array
(
[
t
.
split
(
"
\n
"
)[
0
].
split
(
" "
)
for
t
in
f
.
readlines
()]
[
t
.
split
(
"
\n
"
)[
0
].
split
(
" "
)
for
t
in
f
.
readlines
()]
).
astype
(
np
.
float
)
).
astype
(
float
)
data_list
.
append
(
data
[:,
0
:
self
.
dim
])
data_list
.
append
(
data
[:,
0
:
self
.
dim
])
label_list
.
append
(
data
[:,
6
].
astype
(
np
.
int
))
label_list
.
append
(
data
[:,
6
].
astype
(
int
))
category_list
.
append
(
shapenet
.
synset_dict
[
fn
.
split
(
"/"
)[
-
2
]])
category_list
.
append
(
shapenet
.
synset_dict
[
fn
.
split
(
"/"
)[
-
2
]])
self
.
data
=
data_list
self
.
data
=
data_list
self
.
label
=
label_list
self
.
label
=
label_list
...
@@ -156,6 +156,6 @@ class ShapeNetDataset(Dataset):
...
@@ -156,6 +156,6 @@ class ShapeNetDataset(Dataset):
cat
=
self
.
category
[
i
]
cat
=
self
.
category
[
i
]
if
self
.
mode
==
"train"
:
if
self
.
mode
==
"train"
:
x
=
self
.
translate
(
x
,
size
=
self
.
dim
)
x
=
self
.
translate
(
x
,
size
=
self
.
dim
)
x
=
x
.
astype
(
np
.
float
)
x
=
x
.
astype
(
float
)
y
=
y
.
astype
(
np
.
int
)
y
=
y
.
astype
(
int
)
return
x
,
y
,
cat
return
x
,
y
,
cat
examples/pytorch/rrn/ckpt/rrn-sudoku.pkl
0 → 100644
View file @
15ace31a
File added
examples/pytorch/rrn/sudoku_solver.py
View file @
15ace31a
...
@@ -13,7 +13,7 @@ def solve_sudoku(puzzle):
...
@@ -13,7 +13,7 @@ def solve_sudoku(puzzle):
:param puzzle: an array-like data with shape [9, 9], blank positions are filled with 0
:param puzzle: an array-like data with shape [9, 9], blank positions are filled with 0
:return: a [9, 9] shaped numpy array
:return: a [9, 9] shaped numpy array
"""
"""
puzzle
=
np
.
array
(
puzzle
,
dtype
=
np
.
long
).
reshape
([
-
1
])
puzzle
=
np
.
array
(
puzzle
,
dtype
=
int
).
reshape
([
-
1
])
model_path
=
"ckpt"
model_path
=
"ckpt"
if
not
os
.
path
.
exists
(
model_path
):
if
not
os
.
path
.
exists
(
model_path
):
os
.
mkdir
(
model_path
)
os
.
mkdir
(
model_path
)
...
...
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