Skip to content

Commit 25cc60d

Browse files
committed
update for keras 3.0
1 parent 92bef13 commit 25cc60d

File tree

8 files changed

+181
-180
lines changed

8 files changed

+181
-180
lines changed

kgcnn/layers/casting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def call(self, inputs: list, **kwargs):
402402
"""
403403
attr, graph_id_attr, attr_id, attr_len = inputs
404404
if self.static_output_shape is not None:
405-
target_shape = self.static_output_shape
405+
target_shape = (ops.shape(attr_len)[0], self.static_output_shape[0])
406406
else:
407407
target_shape = (ops.shape(attr_len)[0], ops.amax(attr_len))
408408

training/hyper/hyper_cora.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
{"shape": (), "name": "total_nodes", "dtype": "int64"},
1313
{"shape": (), "name": "total_edges", "dtype": "int64"}
1414
],
15-
"cast_disjoint_kwargs": {"padded_disjoint": False, "static_batched_node_output_shape": None},
15+
"cast_disjoint_kwargs": {"padded_disjoint": False,
16+
"static_batched_node_output_shape": (19793, 70)},
1617
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
1718
"input_edge_embedding": {"input_dim": 25, "output_dim": 1},
1819
"gcn_args": {"units": 140, "use_bias": True, "activation": "relu"},
@@ -78,7 +79,7 @@
7879
{"shape": (), "name": "total_nodes", "dtype": "int64"},
7980
{"shape": (), "name": "total_edges", "dtype": "int64"}
8081
],
81-
"cast_disjoint_kwargs": {"static_batched_node_output_shape": None},
82+
"cast_disjoint_kwargs": {"static_batched_node_output_shape": (19793, 70)},
8283
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
8384
"input_edge_embedding": {"input_dim": 25, "output_dim": 64},
8485
"attention_args": {"units": 140, "use_bias": True, "use_edge_features": True,
@@ -146,7 +147,7 @@
146147
{"shape": (), "name": "total_nodes", "dtype": "int64"},
147148
{"shape": (), "name": "total_edges", "dtype": "int64"}
148149
],
149-
"cast_disjoint_kwargs": {"static_batched_node_output_shape": None},
150+
"cast_disjoint_kwargs": {"static_batched_node_output_shape": (19793, 70)},
150151
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
151152
"input_edge_embedding": {"input_dim": 8, "output_dim": 64},
152153
"attention_args": {"units": 70, "use_bias": True, "use_edge_features": True, "activation": "relu",
@@ -213,7 +214,7 @@
213214
{"shape": (), "name": "total_nodes", "dtype": "int64"},
214215
{"shape": (), "name": "total_edges", "dtype": "int64"}
215216
],
216-
"cast_disjoint_kwargs": {"padded_disjoint": False, "static_batched_node_output_shape": None},
217+
"cast_disjoint_kwargs": {"padded_disjoint": False, "static_batched_node_output_shape": (19793, 70)},
217218
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
218219
"input_edge_embedding": {"input_dim": 25, "output_dim": 1},
219220
"node_mlp_args": {"units": [70, 70], "use_bias": True, "activation": ["relu", "linear"]},
@@ -275,7 +276,7 @@
275276
{"shape": (), "name": "total_nodes", "dtype": "int64"},
276277
{"shape": (), "name": "total_edges", "dtype": "int64"}
277278
],
278-
"cast_disjoint_kwargs": {"padded_disjoint": False, "static_batched_node_output_shape": None},
279+
"cast_disjoint_kwargs": {"padded_disjoint": False, "static_batched_node_output_shape": (19793, 70)},
279280
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
280281
"depth": 4,
281282
"dropout": 0.01,
@@ -336,7 +337,7 @@
336337
{"shape": (), "name": "total_nodes", "dtype": "int64"},
337338
{"shape": (), "name": "total_edges", "dtype": "int64"}
338339
],
339-
"cast_disjoint_kwargs": {"static_batched_node_output_shape": None},
340+
"cast_disjoint_kwargs": {"static_batched_node_output_shape": (19793, 70)},
340341
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
341342
"input_edge_embedding": {"input_dim": 5, "output_dim": 64},
342343
"input_graph_embedding": {"input_dim": 100, "output_dim": 64},

training/hyper/hyper_cora_lu.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{"shape": (), "name": "total_nodes", "dtype": "int64"},
1313
{"shape": (), "name": "total_edges", "dtype": "int64"}
1414
],
15-
"cast_disjoint_kwargs": {"static_batched_node_output_shape": None},
15+
"cast_disjoint_kwargs": {"static_batched_node_output_shape": (2708, 7)},
1616
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
1717
"input_edge_embedding": {"input_dim": 8, "output_dim": 64},
1818
"attention_args": {"units": 32, "use_bias": True, "use_edge_features": True, "activation": "relu",
@@ -79,7 +79,7 @@
7979
{"shape": (), "name": "total_nodes", "dtype": "int64"},
8080
{"shape": (), "name": "total_edges", "dtype": "int64"}
8181
],
82-
"cast_disjoint_kwargs": {"static_batched_node_output_shape": None},
82+
"cast_disjoint_kwargs": {"static_batched_node_output_shape": (2708, 7)},
8383
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
8484
"input_edge_embedding": {"input_dim": 8, "output_dim": 64},
8585
"attention_args": {"units": 32, "use_bias": True, "use_edge_features": True,
@@ -150,7 +150,7 @@
150150
{"shape": (), "name": "total_nodes", "dtype": "int64"},
151151
{"shape": (), "name": "total_edges", "dtype": "int64"}
152152
],
153-
"cast_disjoint_kwargs": {"padded_disjoint": False, "static_batched_node_output_shape": None},
153+
"cast_disjoint_kwargs": {"padded_disjoint": False, "static_batched_node_output_shape": (2708, 7)},
154154
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
155155
"input_edge_embedding": {"input_dim": 25, "output_dim": 1},
156156
"gcn_args": {"units": 64, "use_bias": True, "activation": "relu"},
@@ -217,7 +217,7 @@
217217
{"shape": (), "name": "total_nodes", "dtype": "int64"},
218218
{"shape": (), "name": "total_edges", "dtype": "int64"}
219219
],
220-
"cast_disjoint_kwargs": {"padded_disjoint": False, "static_batched_node_output_shape": None},
220+
"cast_disjoint_kwargs": {"padded_disjoint": False, "static_batched_node_output_shape": (2708, 7)},
221221
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
222222
"input_edge_embedding": {"input_dim": 25, "output_dim": 1},
223223
"node_mlp_args": {"units": [64, 32], "use_bias": True, "activation": ["relu", "linear"]},
@@ -281,7 +281,7 @@
281281
{"shape": (), "name": "total_nodes", "dtype": "int64"},
282282
{"shape": (), "name": "total_edges", "dtype": "int64"}
283283
],
284-
"cast_disjoint_kwargs": {"padded_disjoint": False, "static_batched_node_output_shape": None},
284+
"cast_disjoint_kwargs": {"padded_disjoint": False, "static_batched_node_output_shape": (2708, 7)},
285285
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
286286
"depth": 5,
287287
"dropout": 0.05,
@@ -342,7 +342,7 @@
342342
{"shape": (), "name": "total_nodes", "dtype": "int64"},
343343
{"shape": (), "name": "total_edges", "dtype": "int64"}
344344
],
345-
"cast_disjoint_kwargs": {"static_batched_node_output_shape": None},
345+
"cast_disjoint_kwargs": {"static_batched_node_output_shape": (2708, 7)},
346346
"input_node_embedding": {"input_dim": 95, "output_dim": 64},
347347
"input_edge_embedding": {"input_dim": 5, "output_dim": 64},
348348
"input_graph_embedding": {"input_dim": 100, "output_dim": 64},
Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
OS: posix_linux
1+
OS: nt_win32
22
auc:
3-
- 0.999762237071991
4-
- 0.9993982911109924
5-
- 0.9996947050094604
6-
- 0.9997313618659973
7-
- 0.9998652338981628
3+
- 0.9997970461845398
4+
- 0.9997227787971497
5+
- 0.9996034502983093
6+
- 0.9997959733009338
7+
- 0.9992673397064209
88
backend: tensorflow
99
categorical_accuracy:
10-
- 0.9910950660705566
11-
- 0.9876216053962708
10+
- 0.9921056032180786
1211
- 0.9892004132270813
13-
- 0.9920430183410645
14-
- 0.9925482273101807
12+
- 0.9900845885276794
13+
- 0.9931164979934692
14+
- 0.9866751432418823
1515
cuda_available: 'False'
1616
data_unit: ''
17-
date_time: '2023-09-28 11:58:23'
17+
date_time: '2023-11-10 14:34:15'
1818
device_id: '[LogicalDevice(name=''/device:CPU:0'', device_type=''CPU'')]'
1919
device_memory: '[]'
2020
device_name: '[{}]'
@@ -33,117 +33,117 @@ learning_rate:
3333
- 2.9799999538226984e-05
3434
- 2.9799999538226984e-05
3535
loss:
36-
- 0.05441790074110031
37-
- 0.0716157853603363
38-
- 0.05998317897319794
39-
- 0.04724658280611038
40-
- 0.04499133676290512
36+
- 0.04833434894680977
37+
- 0.05927110090851784
38+
- 0.05427543446421623
39+
- 0.04719273000955582
40+
- 0.07413457334041595
4141
max_auc:
42-
- 0.999762237071991
43-
- 0.9993982911109924
44-
- 0.9996947050094604
45-
- 0.9997313618659973
46-
- 0.9998652338981628
42+
- 0.9997970461845398
43+
- 0.9997227787971497
44+
- 0.9996034502983093
45+
- 0.9997959733009338
46+
- 0.9992673397064209
4747
max_categorical_accuracy:
48-
- 0.9910950660705566
49-
- 0.9876847267150879
48+
- 0.9921056032180786
5049
- 0.9892004132270813
51-
- 0.9920430183410645
52-
- 0.9925482273101807
50+
- 0.9901477694511414
51+
- 0.9931164979934692
52+
- 0.9866751432418823
5353
max_learning_rate:
5454
- 0.0010000000474974513
5555
- 0.0010000000474974513
5656
- 0.0010000000474974513
5757
- 0.0010000000474974513
5858
- 0.0010000000474974513
5959
max_loss:
60-
- 3.398777961730957
61-
- 3.3987607955932617
62-
- 3.39878249168396
63-
- 3.398913860321045
64-
- 3.398898124694824
60+
- 3.398766279220581
61+
- 3.3987977504730225
62+
- 3.3987717628479004
63+
- 3.3988664150238037
64+
- 3.3989439010620117
6565
max_val_auc:
66-
- 0.9488013386726379
67-
- 0.9354034662246704
68-
- 0.9401569962501526
69-
- 0.9472397565841675
70-
- 0.9552340507507324
66+
- 0.9485095143318176
67+
- 0.9415806531906128
68+
- 0.9437487721443176
69+
- 0.9494364261627197
70+
- 0.9393430948257446
7171
max_val_categorical_accuracy:
72-
- 0.6304622292518616
73-
- 0.6145491003990173
74-
- 0.621874213218689
75-
- 0.628347635269165
76-
- 0.6599292755126953
72+
- 0.6430917382240295
73+
- 0.6221268177032471
74+
- 0.6423339247703552
75+
- 0.6339060664176941
76+
- 0.6237999200820923
7777
max_val_loss:
78-
- 0.8457090258598328
79-
- 0.845753014087677
80-
- 0.8460831046104431
81-
- 0.8454264998435974
82-
- 0.8444616198539734
78+
- 0.8462190628051758
79+
- 0.8460386991500854
80+
- 0.8453730344772339
81+
- 0.8446404337882996
82+
- 0.845479428768158
8383
min_auc:
8484
- 0.5
8585
- 0.5
8686
- 0.5
8787
- 0.5
8888
- 0.5
8989
min_categorical_accuracy:
90-
- 0.013073134236037731
91-
- 0.006378678604960442
92-
- 0.015725653618574142
93-
- 0.015472055412828922
94-
- 0.012693400494754314
90+
- 0.010989010334014893
91+
- 0.008210180327296257
92+
- 0.012188960798084736
93+
- 0.014461635611951351
94+
- 0.0143984854221344
9595
min_learning_rate:
9696
- 2.9799999538226984e-05
9797
- 2.9799999538226984e-05
9898
- 2.9799999538226984e-05
9999
- 2.9799999538226984e-05
100100
- 2.9799999538226984e-05
101101
min_loss:
102-
- 0.05441790074110031
103-
- 0.0716157853603363
104-
- 0.05998317897319794
105-
- 0.04724658280611038
106-
- 0.04499133676290512
102+
- 0.04833434894680977
103+
- 0.05927110090851784
104+
- 0.05427543446421623
105+
- 0.04719273000955582
106+
- 0.07413457334041595
107107
min_val_auc:
108-
- 0.5642143487930298
109-
- 0.5480632781982422
110-
- 0.566200315952301
111-
- 0.5362739562988281
112-
- 0.5903472304344177
108+
- 0.5619556903839111
109+
- 0.5503183007240295
110+
- 0.5602461099624634
111+
- 0.5655176639556885
112+
- 0.5490549802780151
113113
min_val_categorical_accuracy:
114-
- 0.06415761262178421
115-
- 0.0426875464618206
116-
- 0.07325082272291183
117-
- 0.041182417422533035
118-
- 0.03183425962924957
114+
- 0.044455669820308685
115+
- 0.022985603660345078
116+
- 0.04319272190332413
117+
- 0.04194037616252899
118+
- 0.05002526938915253
119119
min_val_loss:
120-
- 0.3355126976966858
121-
- 0.3776290714740753
122-
- 0.36266764998435974
123-
- 0.3395977318286896
124-
- 0.30311766266822815
120+
- 0.32970473170280457
121+
- 0.35624369978904724
122+
- 0.345664918422699
123+
- 0.33276599645614624
124+
- 0.3752051293849945
125125
model_class: make_model
126126
model_name: GAT
127127
model_version: ''
128128
multi_target_indices: null
129129
number_histories: 5
130-
seed: 42
130+
seed: 43
131131
time_list: null
132132
val_auc:
133-
- 0.8853158950805664
134-
- 0.8801058530807495
135-
- 0.885858416557312
136-
- 0.8841972351074219
137-
- 0.8946847915649414
133+
- 0.8906697034835815
134+
- 0.8801469802856445
135+
- 0.8841161727905273
136+
- 0.8852816820144653
137+
- 0.8822670578956604
138138
val_categorical_accuracy:
139-
- 0.6158120632171631
140-
- 0.600151538848877
141-
- 0.6115180850028992
142-
- 0.605103611946106
143-
- 0.6336533427238464
139+
- 0.6241475343704224
140+
- 0.6026774644851685
141+
- 0.6168224215507507
142+
- 0.6184942126274109
143+
- 0.6162203550338745
144144
val_loss:
145-
- 0.5910420417785645
146-
- 0.6129895448684692
147-
- 0.5975256562232971
148-
- 0.600094735622406
149-
- 0.5462737083435059
145+
- 0.5637747049331665
146+
- 0.6208769679069519
147+
- 0.5982853770256042
148+
- 0.5941001176834106
149+
- 0.6143744587898254
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"model": {"class_name": "make_model", "module_name": "kgcnn.literature.GAT", "config": {"name": "GAT", "inputs": [{"shape": [null, 8710], "name": "node_attributes", "dtype": "float32"}, {"shape": [null, 1], "name": "edge_weights", "dtype": "float32"}, {"shape": [null, 2], "name": "edge_indices", "dtype": "int64"}, {"shape": [], "name": "total_nodes", "dtype": "int64"}, {"shape": [], "name": "total_edges", "dtype": "int64"}], "cast_disjoint_kwargs": {}, "input_node_embedding": {"input_dim": 95, "output_dim": 64}, "input_edge_embedding": {"input_dim": 8, "output_dim": 64}, "attention_args": {"units": 70, "use_bias": true, "use_edge_features": true, "activation": "relu", "use_final_activation": false, "has_self_loops": true}, "pooling_nodes_args": {"pooling_method": "scatter_mean"}, "depth": 1, "attention_heads_num": 10, "attention_heads_concat": false, "verbose": 10, "output_embedding": "node", "output_mlp": {"use_bias": [true, true, false], "units": [70, 70, 70], "activation": ["relu", "relu", "softmax"]}}}, "training": {"fit": {"batch_size": 1, "epochs": 250, "validation_freq": 10, "verbose": 2, "callbacks": [{"class_name": "kgcnn>LinearLearningRateScheduler", "config": {"learning_rate_start": 0.001, "learning_rate_stop": 1e-05, "epo_min": 200, "epo": 250, "verbose": 0}}]}, "compile": {"optimizer": {"class_name": "Adam", "config": {"learning_rate": 0.001}}, "loss": "categorical_crossentropy", "weighted_metrics": ["categorical_accuracy", {"class_name": "AUC", "config": {"name": "auc"}}]}, "cross_validation": {"class_name": "KFold", "config": {"n_splits": 5, "random_state": 42, "shuffle": true}}, "multi_target_indices": null}, "data": {}, "info": {"postfix": "", "postfix_file": "", "kgcnn_version": "4.0.0"}, "dataset": {"class_name": "CoraDataset", "module_name": "kgcnn.data.datasets.CoraDataset", "config": {}, "methods": [{"map_list": {"method": "make_undirected_edges"}}, {"map_list": {"method": "add_edge_self_loops"}}, {"map_list": {"method": "normalize_edge_weights_sym"}}, {"map_list": {"method": "count_nodes_and_edges"}}]}}
1+
{"model": {"class_name": "make_model", "module_name": "kgcnn.literature.GAT", "config": {"name": "GAT", "inputs": [{"shape": [null, 8710], "name": "node_attributes", "dtype": "float32"}, {"shape": [null, 1], "name": "edge_weights", "dtype": "float32"}, {"shape": [null, 2], "name": "edge_indices", "dtype": "int64"}, {"shape": [], "name": "total_nodes", "dtype": "int64"}, {"shape": [], "name": "total_edges", "dtype": "int64"}], "cast_disjoint_kwargs": {"static_batched_node_output_shape": [19793, 70]}, "input_node_embedding": {"input_dim": 95, "output_dim": 64}, "input_edge_embedding": {"input_dim": 8, "output_dim": 64}, "attention_args": {"units": 70, "use_bias": true, "use_edge_features": true, "activation": "relu", "use_final_activation": false, "has_self_loops": true}, "pooling_nodes_args": {"pooling_method": "scatter_mean"}, "depth": 1, "attention_heads_num": 10, "attention_heads_concat": false, "verbose": 10, "output_embedding": "node", "output_mlp": {"use_bias": [true, true, false], "units": [70, 70, 70], "activation": ["relu", "relu", "softmax"]}}}, "training": {"fit": {"batch_size": 1, "epochs": 250, "validation_freq": 10, "verbose": 2, "callbacks": [{"class_name": "kgcnn>LinearLearningRateScheduler", "config": {"learning_rate_start": 0.001, "learning_rate_stop": 1e-05, "epo_min": 200, "epo": 250, "verbose": 0}}]}, "compile": {"optimizer": {"class_name": "Adam", "config": {"learning_rate": 0.001}}, "loss": "categorical_crossentropy", "weighted_metrics": ["categorical_accuracy", {"class_name": "AUC", "config": {"name": "auc"}}]}, "cross_validation": {"class_name": "KFold", "config": {"n_splits": 5, "random_state": 42, "shuffle": true}}, "multi_target_indices": null}, "data": {}, "info": {"postfix": "", "postfix_file": "", "kgcnn_version": "4.0.0"}, "dataset": {"class_name": "CoraDataset", "module_name": "kgcnn.data.datasets.CoraDataset", "config": {}, "methods": [{"map_list": {"method": "make_undirected_edges"}}, {"map_list": {"method": "add_edge_self_loops"}}, {"map_list": {"method": "normalize_edge_weights_sym"}}, {"map_list": {"method": "count_nodes_and_edges"}}]}}

0 commit comments

Comments
 (0)