Skip to content

Instantly share code, notes, and snippets.

@mariogeiger
Created September 28, 2022 18:38
Show Gist options
  • Select an option

  • Save mariogeiger/999d3505f4d4289f3aa786e61fd4d6dd to your computer and use it in GitHub Desktop.

Select an option

Save mariogeiger/999d3505f4d4289f3aa786e61fd4d6dd to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"from e3nn.nn.models.v2106.gate_points_networks import SimpleNetwork, radius_graph"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"8.2"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# determine the average number of neighbors\n",
"\n",
"r_max = 1.0\n",
"pos = torch.randn(100, 3)\n",
"r = torch.cdist(pos, pos)\n",
"index = ((r < r_max) & (r > 0)).nonzero().T\n",
"\n",
"index.shape[1] / 100"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"network = SimpleNetwork(\n",
" irreps_in=\"32x0e\",\n",
" irreps_out=\"0e\",\n",
" max_radius=1.0,\n",
" num_neighbors=8.0,\n",
" num_nodes=100,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"50x0e+50x1o+50x2e [0.9967367053031921, 0.9615816473960876, 0.9536312222480774]\n",
"50x0e+50x1o+50x1e+50x2o+50x2e [1.0500167608261108, 0.9709723591804504, 1.241517186164856, 1.1689879894256592, 0.9532064199447632]\n",
"50x0o+50x0e+50x1o+50x1e+50x2o+50x2e [0.9403162002563477, 1.178753137588501, 0.9169595241546631, 1.3434650897979736, 1.2201933860778809, 0.8891504406929016]\n"
]
},
{
"data": {
"text/plain": [
"tensor([[-2.4210]], grad_fn=<DivBackward0>)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"network({\n",
" \"pos\": torch.randn(100, 3),\n",
" \"x\": torch.randn(100, 32),\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.6 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "f26faf9d33dc8b83cd077f62f5d9010e5bc51611e479f12b96223e2da63ba699"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment