spam-ml-mx-v2

WIP
git clone git://archive.git.mtrnord.blog/MTRNord/spam-ml-mx-v2.git
Log | Files | Refs | LICENSE

commit 870ab574171c7ab57f9e57c893ae63d8c8301fb0
parent 8609c7af1dbd4d7b640ce220677a38fbb7ef1dc2
Author: Marcel <MTRNord@users.noreply.github.com>
Date:   Fri, 10 Mar 2023 15:21:07 +0000

Update devontainer,requirements and model

Diffstat:
M.devcontainer/devcontainer.json | 5++---
A.gitignore | 2++
Mmodel.ipynb | 132++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mrequirements.txt | 7+++++--
4 files changed, 137 insertions(+), 9 deletions(-)

diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json @@ -13,8 +13,7 @@ "installCudnn": true, "cudaVersion": "11.7", "cudnnVersion": "8.5.0.96" - }, - "ghcr.io/devcontainers/features/python:1": {} + } }, - "postCreateCommand": "pip3 install --user -r requirements.txt" + "postCreateCommand": "python3 -m pip install --user -r requirements.txt" } \ No newline at end of file diff --git a/.gitignore b/.gitignore @@ -0,0 +1 @@ +.fastai/ +\ No newline at end of file diff --git a/model.ipynb b/model.ipynb @@ -2,25 +2,149 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import fastai.callback.tensorboard\n", "from fastai.text.all import *\n", - "import os\n", - "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"\"\n" + "import os\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " <div>\n", + " <progress value='144441344' class='' max='144440600' style='width:300px; height:20px; vertical-align: middle;'></progress>\n", + " 100.00% [144441344/144440600 00:04&lt;00:00]\n", + " </div>\n", + " " + ], + "text/plain": [ + "<IPython.core.display.HTML object>" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "(#4) [Path('/workspaces/spam-ml-mx-v2/.fastai/imdb/train/pos'),Path('/workspaces/spam-ml-mx-v2/.fastai/imdb/train/unsupBow.feat'),Path('/workspaces/spam-ml-mx-v2/.fastai/imdb/train/labeledBow.feat'),Path('/workspaces/spam-ml-mx-v2/.fastai/imdb/train/neg')]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cwd = os.getcwd()\n", + "p = Path(f\"{cwd}/.fastai\")\n", + "if not p.exists():\n", + " p.mkdir()\n", + "path = untar_data(URLs.IMDB, data=p)\n", + "(path/'train').ls()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " <div>\n", + " <progress value='19011' class='' max='100002' style='width:300px; height:20px; vertical-align: middle;'></progress>\n", + " 19.01% [19011/100002 01:47&lt;07:37]\n", + " </div>\n", + " " + ], + "text/plain": [ + "<IPython.core.display.HTML object>" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "source = untar_data(URLs.IMDB, data=p)\n", + "dls = TextDataLoaders.from_folder(source, valid=\"test\", bs=64)\n", + "dls.show_batch()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "learn = text_classifier_learner(dls, AWD_LSTM, drop_mult=0.5, metrics=accuracy,\n", + " cbs=TensorBoardCallback(cwd/'tmp'/'runs'/'tb', trace_model=True))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "learn.fine_tune(4, 1e-2)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "learn.fine_tune(4, 1e-2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "learn.show_results()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "learn.predict(\"I really liked that movie!\")\n" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "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.4" }, "orig_nbformat": 4, diff --git a/requirements.txt b/requirements.txt @@ -2,4 +2,7 @@ torch torchaudio torchvision fastai -numpy -\ No newline at end of file +numpy +ipykernel +ipywidgets +tensorboard +\ No newline at end of file