{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# https://www.kaggle.com/code/lyomega/compile-your-own-version\nimport torch\nprint(torch.__version__,torch.version.cuda)","metadata":{"execution":{"iopub.status.busy":"2023-01-25T17:49:21.091433Z","iopub.execute_input":"2023-01-25T17:49:21.091860Z","iopub.status.idle":"2023-01-25T17:49:22.847721Z","shell.execute_reply.started":"2023-01-25T17:49:21.091756Z","shell.execute_reply":"2023-01-25T17:49:22.846639Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# You can specify the version you want. It will take a while to compile.\n!pip install torch_cluster torch_scatter torch_sparse torch_spline_conv torch_geometric","metadata":{"execution":{"iopub.status.busy":"2023-01-25T17:49:22.852610Z","iopub.execute_input":"2023-01-25T17:49:22.853736Z","iopub.status.idle":"2023-01-25T18:44:26.326377Z","shell.execute_reply.started":"2023-01-25T17:49:22.853695Z","shell.execute_reply":"2023-01-25T18:44:26.325186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import torch\nfrom torch import Tensor\nfrom torch.nn import Sequential, Linear, ReLU\nfrom torch_geometric.nn import MessagePassing\n\n# check if the installation is successful\nclass EdgeConv(MessagePassing):\n    def __init__(self, in_channels, out_channels):\n        super().__init__(aggr=\"max\")  # \"Max\" aggregation.\n        self.mlp = Sequential(\n            Linear(2 * in_channels, out_channels),\n            ReLU(),\n            Linear(out_channels, out_channels),\n        )\n\n    def forward(self, x: Tensor, edge_index: Tensor) -> Tensor:\n        # x: Node feature matrix of shape [num_nodes, in_channels]\n        # edge_index: Graph connectivity matrix of shape [2, num_edges]\n        return self.propagate(edge_index, x=x)  # shape [num_nodes, out_channels]\n\n    def message(self, x_j: Tensor, x_i: Tensor) -> Tensor:\n        # x_j: Source node features of shape [num_edges, in_channels]\n        # x_i: Target node features of shape [num_edges, in_channels]\n        edge_features = torch.cat([x_i, x_j - x_i], dim=-1)\n        return self.mlp(edge_features)  # shape [num_edges, out_channels]\n\nEdgeConv","metadata":{"execution":{"iopub.status.busy":"2023-01-25T18:44:26.328427Z","iopub.execute_input":"2023-01-25T18:44:26.328831Z","iopub.status.idle":"2023-01-25T18:44:30.067545Z","shell.execute_reply.started":"2023-01-25T18:44:26.328783Z","shell.execute_reply":"2023-01-25T18:44:30.066541Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install git+https://github.com/graphnet-team/graphnet.git","metadata":{"execution":{"iopub.status.busy":"2023-01-25T18:49:15.642810Z","iopub.execute_input":"2023-01-25T18:49:15.643624Z","iopub.status.idle":"2023-01-25T18:49:50.058352Z","shell.execute_reply.started":"2023-01-25T18:49:15.643580Z","shell.execute_reply":"2023-01-25T18:49:50.057107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# copy the wheels\n!cp -r ~/.cache/pip/wheels/**/**/**/**/*.whl .","metadata":{"execution":{"iopub.status.busy":"2023-01-25T18:51:31.486561Z","iopub.execute_input":"2023-01-25T18:51:31.486972Z","iopub.status.idle":"2023-01-25T18:51:32.451836Z","shell.execute_reply.started":"2023-01-25T18:51:31.486934Z","shell.execute_reply":"2023-01-25T18:51:32.450482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from torch_geometric.data import Data, Dataset\nfrom torch_geometric.loader import DataLoader","metadata":{"execution":{"iopub.status.busy":"2023-01-25T18:51:45.317015Z","iopub.execute_input":"2023-01-25T18:51:45.317405Z","iopub.status.idle":"2023-01-25T18:51:45.322888Z","shell.execute_reply.started":"2023-01-25T18:51:45.317371Z","shell.execute_reply":"2023-01-25T18:51:45.321815Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!python -m pip download --dest . --no-cache git+https://github.com/graphnet-team/graphnet.git","metadata":{"execution":{"iopub.status.busy":"2023-01-25T18:56:31.096586Z","iopub.execute_input":"2023-01-25T18:56:31.096984Z","iopub.status.idle":"2023-01-25T18:57:34.703119Z","shell.execute_reply.started":"2023-01-25T18:56:31.096949Z","shell.execute_reply":"2023-01-25T18:57:34.701950Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}