{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "kernelspec": { "display_name": "TensorFlow 2.3 on Python 3.6 (CUDA 10.1)", "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.6.9" }, "colab": { "name": "8-1.quadratic_cost.ipynb", "provenance": [] } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "BDmLbe8axYoc" }, "source": [ "# 이차 비용 함수" ] }, { "cell_type": "markdown", "metadata": { "id": "klcVqmGVxYoe" }, "source": [ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/rickiepark/dl-illustrated/blob/master/notebooks/8-1.quadratic_cost.ipynb)" ] }, { "cell_type": "code", "metadata": { "id": "mQibxKQ6xYoe" }, "source": [ "def squared_error(y, yhat):\n", " return (y - yhat)**2" ], "execution_count": 1, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "00cdcaILxYof", "outputId": "6bc8d10e-aeb0-4283-edfb-bad8ac7a1831", "colab": { "base_uri": "https://localhost:8080/" } }, "source": [ "squared_error(1, 1)" ], "execution_count": 2, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "0" ] }, "metadata": {}, "execution_count": 2 } ] }, { "cell_type": "code", "metadata": { "id": "tFs6b--FxYog", "outputId": "83cb0f3b-0043-447a-f65f-b5e8f13f3df1", "colab": { "base_uri": "https://localhost:8080/" } }, "source": [ "squared_error(1, 0.9997)" ], "execution_count": 3, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "8.999999999998017e-08" ] }, "metadata": {}, "execution_count": 3 } ] }, { "cell_type": "code", "metadata": { "id": "t53085P2xYog", "outputId": "e5d25d10-ec4c-4ee2-f175-a4bc24614563", "colab": { "base_uri": "https://localhost:8080/" } }, "source": [ "squared_error(1, 0.9)" ], "execution_count": 4, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "0.009999999999999995" ] }, "metadata": {}, "execution_count": 4 } ] }, { "cell_type": "code", "metadata": { "id": "zrWt14ZgxYog", "outputId": "af188470-5cee-412c-d8ff-e9bb16bf0431", "colab": { "base_uri": "https://localhost:8080/" } }, "source": [ "squared_error(1, 0.6)" ], "execution_count": 5, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "0.16000000000000003" ] }, "metadata": {}, "execution_count": 5 } ] }, { "cell_type": "code", "metadata": { "id": "LGB5qBKKxYog", "outputId": "1053935e-a9ce-4d9f-cb9d-f3653e226981", "colab": { "base_uri": "https://localhost:8080/" } }, "source": [ "squared_error(1, 0.1192)" ], "execution_count": 6, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "0.77580864" ] }, "metadata": {}, "execution_count": 6 } ] }, { "cell_type": "code", "metadata": { "id": "13Qg81mZxYoh", "outputId": "965afab0-70bb-4bb9-836f-83e77bc97e0c", "colab": { "base_uri": "https://localhost:8080/" } }, "source": [ "squared_error(0, 0.1192)" ], "execution_count": 7, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "0.01420864" ] }, "metadata": {}, "execution_count": 7 } ] }, { "cell_type": "code", "metadata": { "id": "J0897HFTxYoh", "outputId": "f59e5f42-4acc-4da7-ee91-b5c788422e3e", "colab": { "base_uri": "https://localhost:8080/" } }, "source": [ "squared_error(1, 1-0.1192)" ], "execution_count": 8, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "0.014208639999999993" ] }, "metadata": {}, "execution_count": 8 } ] } ] }