Skip to content

Commit

Permalink
Fix pre-commit formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lucmos committed Sep 16, 2023
1 parent d28ab25 commit 5ec4428
Showing 1 changed file with 112 additions and 165 deletions.
277 changes: 112 additions & 165 deletions notebooks/demo.ipynb
Original file line number Diff line number Diff line change
@@ -1,171 +1,118 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "PULWYp1mZIdl"
},
"outputs": [],
"source": [
"from latentis.relative.projection import Projections\n",
"from latentis.relative.projection import RelativeProjector\n",
"from latentis.transforms import Transforms\n",
"\n",
"import torch"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "QETgBS_lah0I"
},
"outputs": [],
"source": [
"x = torch.randn(5, 10)\n",
"anchors = x[:3]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"provenance": []
"base_uri": "https://localhost:8080/"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
"id": "tB96Jvutanb8",
"outputId": "50eb1648-7444-4486-e42a-ee8a8ba4b2d7"
},
"outputs": [],
"source": [
"RelativeProjector(\n",
" projection=Projections.COSINE, anchors=anchors, abs_transforms=Transforms.StandardScaling(), rel_transforms=None\n",
")(x=x)"
]
},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "C-BKbOfHZAkx"
},
"outputs": [],
"source": [
"!pip install latentis\n",
"!pip install backports.strenum # I forgot to add this to the dependencies of the package"
]
},
{
"cell_type": "code",
"source": [
"from latentis.relative.projection import Projections\n",
"from latentis.relative.projection import RelativeProjector\n",
"from latentis.transforms import Transforms\n",
"\n",
"import torch"
],
"metadata": {
"id": "PULWYp1mZIdl"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"x = torch.randn(5, 10)\n",
"anchors = x[:3]"
],
"metadata": {
"id": "QETgBS_lah0I"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"RelativeProjector(\n",
" projection=Projections.COSINE,\n",
" anchors=anchors,\n",
" abs_transforms=Transforms.StandardScaling(),\n",
" rel_transforms=None\n",
")(x=x)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "tB96Jvutanb8",
"outputId": "50eb1648-7444-4486-e42a-ee8a8ba4b2d7"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"tensor([[ 1.0000, -0.6172, -0.3320],\n",
" [-0.6172, 1.0000, -0.5372],\n",
" [-0.3320, -0.5372, 1.0000],\n",
" [-0.1798, 0.3990, -0.2856],\n",
" [ 0.0536, -0.2391, 0.2292]])"
]
},
"metadata": {},
"execution_count": 4
}
]
},
{
"cell_type": "code",
"source": [
"RelativeProjector(\n",
" projection=Projections.COSINE,\n",
" abs_transforms=Transforms.StandardScaling(),\n",
" rel_transforms=None\n",
")(x=x, anchors=anchors)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "keHv66YPZtY6",
"outputId": "add9119a-20d3-4b5a-81bf-51d4224d2bbd"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"tensor([[ 1.0000, -0.6172, -0.3320],\n",
" [-0.6172, 1.0000, -0.5372],\n",
" [-0.3320, -0.5372, 1.0000],\n",
" [-0.1798, 0.3990, -0.2856],\n",
" [ 0.0536, -0.2391, 0.2292]])"
]
},
"metadata": {},
"execution_count": 5
}
]
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
{
"cell_type": "code",
"source": [
"projector = RelativeProjector(\n",
" anchors=anchors,\n",
" projection=Projections.COSINE,\n",
" abs_transforms=Transforms.StandardScaling(),\n",
" rel_transforms=Transforms.L2()\n",
")\n",
"projector(x=x)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "h6ZyakpmcKCa",
"outputId": "b0e32f91-97a9-4451-b25c-2445339a2787"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"tensor([[ 0.8189, -0.5054, -0.2719],\n",
" [-0.4777, 0.7739, -0.4158],\n",
" [-0.2807, -0.4542, 0.8455],\n",
" [-0.3440, 0.7635, -0.5465],\n",
" [ 0.1597, -0.7126, 0.6831]])"
]
},
"metadata": {},
"execution_count": 6
}
]
"id": "keHv66YPZtY6",
"outputId": "add9119a-20d3-4b5a-81bf-51d4224d2bbd"
},
"outputs": [],
"source": [
"RelativeProjector(projection=Projections.COSINE, abs_transforms=Transforms.StandardScaling(), rel_transforms=None)(\n",
" x=x, anchors=anchors\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "2NZKpscRcZRi"
},
"execution_count": null,
"outputs": []
}
]
}
"id": "h6ZyakpmcKCa",
"outputId": "b0e32f91-97a9-4451-b25c-2445339a2787"
},
"outputs": [],
"source": [
"projector = RelativeProjector(\n",
" anchors=anchors,\n",
" projection=Projections.COSINE,\n",
" abs_transforms=Transforms.StandardScaling(),\n",
" rel_transforms=Transforms.L2(),\n",
")\n",
"projector(x=x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "2NZKpscRcZRi"
},
"outputs": [],
"source": []
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"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.9.18"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit 5ec4428

Please sign in to comment.