{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Interpolation Layer\n", "\n", "Create an Interpolation relation in the neural network model. \n", "\n", "This block performs linear interpolation of an input tensor `x` given two vectors of points." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>-- nnodely_v1.5.0 --<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" ] } ], "source": [ "# uncomment the command below to install the nnodely package\n", "#!pip install nnodely\n", "\n", "from nnodely import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Basic Usage\n", "\n", "Create an interpolation layer passing two vectors of points. the two vectors must have the same shape" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "x = Input('x')\n", "interpolation = Interpolation(x_points=[1.0, 2.0, 3.0, 4.0],y_points=[1.0, 4.0, 9.0, 16.0])(x.last())\n", "out = Output('out',interpolation)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Linear Interpolation\n", "\n", "Create a linear interpolation layer passing two vectors of points.\n", "\n", "!! Note that the points do not necessarily need to be ordered" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[33m[check_names] The name 'out' is already in defined as NeuObj but it is overwritten.\u001b[0m\n" ] } ], "source": [ "y = Input('y')\n", "interpolation = Interpolation(x_points=[1.0, 4.0, 3.0, 2.0],y_points=[1.0, 16.0, 9.0, 4.0], mode='linear')(y.last())\n", "out = Output('out',interpolation)" ] } ], "metadata": { "kernelspec": { "display_name": "venv (3.11.4)", "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.11.4" } }, "nbformat": 4, "nbformat_minor": 2 }