{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "交差検証における損失の目安を知る" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "import torch" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 100%正しい場合\n", "torch.nn.functional.cross_entropy(\n", " torch.Tensor([[0,1]]),\n", " torch.Tensor([[0,1]])\n", ")" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "tensor(0.3133)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 100%誤っている場合\n", "torch.nn.functional.cross_entropy(\n", " torch.Tensor([[0,1]]),\n", " torch.Tensor([[1,0]])\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "chiikawa-yonezu", "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.7" } }, "nbformat": 4, "nbformat_minor": 2 }