print(args)
Namespace(batch_size=32, capsule_dimensions=8, epochs=100, gcn_filters=20, gcn_layers=2, inner_attention_dimension=20, lambd=0.5, learning_rate=0.001, number_of_capsules=8, prediction_path=’…/output/watts_predictions.csv’, test_graph_folder=’…/input/test/’, theta=0.1, train_graph_folder=’…/input/train/’, weight_decay=1e-06)
vars 将对象的属性键值变成dict字典
args = vars(args)
print(args)
{‘train_graph_folder’: ‘…/input/train/’, ‘test_graph_folder’: ‘…/input/test/’, ‘prediction_path’: ‘…/output/watts_predictions.csv’, ‘epochs’: 100, ‘batch_size’: 32, ‘gcn_filters’: 20, ‘gcn_layers’: 2, ‘inner_attention_dimension’: 20, ‘capsule_dimensions’: 8, ‘number_of_capsules’: 8, ‘weight_decay’: 1e-06, ‘learning_rate’: 0.001, ‘lambd’: 0.5, ‘theta’: 0.1}
将字典排序后变成列表的列表
keys = sorted(args.keys())
rows = [["Parameter", "Value"]] + [[k.replace("_"," ").capitalize(),args[k]] for k in keys]
print(rows)
[[‘Parameter’, ‘Value’], [‘Batch size’, 32], [‘Capsule dimensions’, 8], [‘Epochs’, 100], [‘Gcn filters’, 20], [‘Gcn layers’, 2], [‘Inner attention dimension’, 20], [‘Lambd’, 0.5], [‘Learning rate’, 0.001], [‘Number of capsules’, 8], [‘Prediction path’, ‘…/output/watts_predictions.csv’], [‘Test graph folder’, ‘…/input/test/’], [‘Theta’, 0.1], [‘Train graph folder’, ‘…/input/train/’], [‘Weight decay’, 1e-06]]
将列表输入texttable 可视化打印
t = Texttable()
t.add_rows(rows)
print(t.draw())
+---------------------------+---------------------------------+
| Parameter | Value |
+===========================+=================================+
| Batch size | 32 |
+---------------------------+---------------------------------+
| Capsule dimensions | 8 |
+---------------------------+---------------------------------+
| Epochs | 100 |
+---------------------------+---------------------------------+
| Gcn filters | 20 |
+---------------------------+---------------------------------+
| Gcn layers | 2 |
+---------------------------+---------------------------------+
| Inner attention dimension | 20 |
+---------------------------+---------------------------------+
| Lambd | 0.500 |
+---------------------------+---------------------------------+
| Learning rate | 0.001 |
+---------------------------+---------------------------------+
| Number of capsules | 8 |
+---------------------------+---------------------------------+
| Prediction path | ../output/watts_predictions.csv |
+---------------------------+---------------------------------+
| Test graph folder | ../input/test/ |
+---------------------------+---------------------------------+
| Theta | 0.100 |
+---------------------------+---------------------------------+
| Train graph folder | ../input/train/ |
+---------------------------+---------------------------------+
| Weight decay | 0.000 |
+---------------------------+---------------------------------+