This commit is contained in:
Adrian Charkiewicz 2022-04-17 19:33:40 +02:00
parent 468abe6648
commit e762fcd010
16 changed files with 2761 additions and 51 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

8
.idea/ium_444354.iml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ium_444354.iml" filepath="$PROJECT_DIR$/.idea/ium_444354.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

3
.jovianrc Normal file
View File

@ -0,0 +1,3 @@
{
"notebooks": {}
}

View File

@ -8,20 +8,27 @@ RUN apt install python3-pip -y
RUN apt install unzip -y
RUN pip3 install --upgrade pip
RUN pip3 install --upgrade Pillow
RUN pip3 install kaggle
RUN pip3 install pandas
RUN pip3 install scikit-learn
RUN pip3 install matplotlib
RUN mkdir ~/.kaggle/
COPY ./script.sh ./
RUN chmod a+x ./script.sh
RUN pip3 install jovian
RUN pip3 install torch
RUN pip3 install seaborn
RUN pip3 install torchvision
# COPY ./script.sh ./
COPY ./runTrain.sh ./runTrain.sh
# RUN chmod a+x ./script.sh
# Create app directory in image
WORKDIR /app
COPY ./winequality-red.csv ./
# Copy init dataset script to /app directory in image
COPY ./data_processing.py ./
# Download kaggle dataset
#RUN kaggle datasets download -d uciml/red-wine-quality-cortez-et-al-2009
#RUN unzip -o red-wine-quality-cortez-et-al-2009.zip
COPY ./pytorch/pytorch.py ./
# Script executed after docker run
CMD python3 ./data_processing.py
# CMD python3 ./pytorch.py
COPY ./runTrain.sh ./
RUN chmod a+x ./runTrain.sh
RUN ./runTrain.sh

View File

@ -0,0 +1,531 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 18,
"id": "e1c5e25d",
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"import jovian\n",
"import torchvision\n",
"import matplotlib\n",
"import torch.nn as nn\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"import torch.nn.functional as F\n",
"from torchvision.datasets.utils import download_url\n",
"from torch.utils.data import DataLoader, TensorDataset, random_split\n",
"import random\n",
"import os\n",
"import sys"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "c77ff6aa",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>fixed acidity</th>\n",
" <th>volatile acidity</th>\n",
" <th>citric acid</th>\n",
" <th>residual sugar</th>\n",
" <th>chlorides</th>\n",
" <th>free sulfur dioxide</th>\n",
" <th>total sulfur dioxide</th>\n",
" <th>density</th>\n",
" <th>pH</th>\n",
" <th>sulphates</th>\n",
" <th>alcohol</th>\n",
" <th>quality</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>7.4</td>\n",
" <td>0.70</td>\n",
" <td>0.00</td>\n",
" <td>1.9</td>\n",
" <td>0.076</td>\n",
" <td>11.0</td>\n",
" <td>34.0</td>\n",
" <td>0.9978</td>\n",
" <td>3.51</td>\n",
" <td>0.56</td>\n",
" <td>9.4</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>7.8</td>\n",
" <td>0.88</td>\n",
" <td>0.00</td>\n",
" <td>2.6</td>\n",
" <td>0.098</td>\n",
" <td>25.0</td>\n",
" <td>67.0</td>\n",
" <td>0.9968</td>\n",
" <td>3.20</td>\n",
" <td>0.68</td>\n",
" <td>9.8</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>7.8</td>\n",
" <td>0.76</td>\n",
" <td>0.04</td>\n",
" <td>2.3</td>\n",
" <td>0.092</td>\n",
" <td>15.0</td>\n",
" <td>54.0</td>\n",
" <td>0.9970</td>\n",
" <td>3.26</td>\n",
" <td>0.65</td>\n",
" <td>9.8</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>11.2</td>\n",
" <td>0.28</td>\n",
" <td>0.56</td>\n",
" <td>1.9</td>\n",
" <td>0.075</td>\n",
" <td>17.0</td>\n",
" <td>60.0</td>\n",
" <td>0.9980</td>\n",
" <td>3.16</td>\n",
" <td>0.58</td>\n",
" <td>9.8</td>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>7.4</td>\n",
" <td>0.70</td>\n",
" <td>0.00</td>\n",
" <td>1.9</td>\n",
" <td>0.076</td>\n",
" <td>11.0</td>\n",
" <td>34.0</td>\n",
" <td>0.9978</td>\n",
" <td>3.51</td>\n",
" <td>0.56</td>\n",
" <td>9.4</td>\n",
" <td>5</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" fixed acidity volatile acidity citric acid residual sugar chlorides \\\n",
"0 7.4 0.70 0.00 1.9 0.076 \n",
"1 7.8 0.88 0.00 2.6 0.098 \n",
"2 7.8 0.76 0.04 2.3 0.092 \n",
"3 11.2 0.28 0.56 1.9 0.075 \n",
"4 7.4 0.70 0.00 1.9 0.076 \n",
"\n",
" free sulfur dioxide total sulfur dioxide density pH sulphates \\\n",
"0 11.0 34.0 0.9978 3.51 0.56 \n",
"1 25.0 67.0 0.9968 3.20 0.68 \n",
"2 15.0 54.0 0.9970 3.26 0.65 \n",
"3 17.0 60.0 0.9980 3.16 0.58 \n",
"4 11.0 34.0 0.9978 3.51 0.56 \n",
"\n",
" alcohol quality \n",
"0 9.4 5 \n",
"1 9.8 5 \n",
"2 9.8 5 \n",
"3 9.8 6 \n",
"4 9.4 5 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataframe_raw = pd.read_csv(\"winequality-red.csv\")\n",
"dataframe_raw.head()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "99f42861",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(['fixed acidity',\n",
" 'volatile acidity',\n",
" 'citric acid',\n",
" 'residual sugar',\n",
" 'chlorides',\n",
" 'free sulfur dioxide',\n",
" 'total sulfur dioxide',\n",
" 'density',\n",
" 'pH',\n",
" 'sulphates',\n",
" 'alcohol'],\n",
" ['quality'])"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"input_cols=list(dataframe_raw.columns)[:-1]\n",
"output_cols = ['quality']\n",
"input_cols,output_cols"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "87011c12",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(array([[ 7.4 , 0.7 , 0. , ..., 3.51 , 0.56 , 9.4 ],\n",
" [ 7.8 , 0.88 , 0. , ..., 3.2 , 0.68 , 9.8 ],\n",
" [ 7.8 , 0.76 , 0.04 , ..., 3.26 , 0.65 , 9.8 ],\n",
" ...,\n",
" [ 6.3 , 0.51 , 0.13 , ..., 3.42 , 0.75 , 11. ],\n",
" [ 5.9 , 0.645, 0.12 , ..., 3.57 , 0.71 , 10.2 ],\n",
" [ 6. , 0.31 , 0.47 , ..., 3.39 , 0.66 , 11. ]]),\n",
" array([[5],\n",
" [5],\n",
" [5],\n",
" ...,\n",
" [6],\n",
" [5],\n",
" [6]], dtype=int64))"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def dataframe_to_arrays(dataframe):\n",
" dataframe1 = dataframe_raw.copy(deep=True)\n",
" inputs_array = dataframe1[input_cols].to_numpy()\n",
" targets_array = dataframe1[output_cols].to_numpy()\n",
" return inputs_array, targets_array\n",
"\n",
"inputs_array, targets_array = dataframe_to_arrays(dataframe_raw)\n",
"inputs_array, targets_array"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "705fb5b7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(tensor([[ 7.4000, 0.7000, 0.0000, ..., 3.5100, 0.5600, 9.4000],\n",
" [ 7.8000, 0.8800, 0.0000, ..., 3.2000, 0.6800, 9.8000],\n",
" [ 7.8000, 0.7600, 0.0400, ..., 3.2600, 0.6500, 9.8000],\n",
" ...,\n",
" [ 6.3000, 0.5100, 0.1300, ..., 3.4200, 0.7500, 11.0000],\n",
" [ 5.9000, 0.6450, 0.1200, ..., 3.5700, 0.7100, 10.2000],\n",
" [ 6.0000, 0.3100, 0.4700, ..., 3.3900, 0.6600, 11.0000]]),\n",
" tensor([[5.],\n",
" [5.],\n",
" [5.],\n",
" ...,\n",
" [6.],\n",
" [5.],\n",
" [6.]]))"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"inputs = torch.from_numpy(inputs_array).type(torch.float)\n",
"targets = torch.from_numpy(targets_array).type(torch.float)\n",
"inputs,targets"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "71f14b4a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<torch.utils.data.dataset.TensorDataset at 0x1f334183760>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataset = TensorDataset(inputs, targets)\n",
"dataset"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "c4f8cd40",
"metadata": {},
"outputs": [],
"source": [
"train_ds, val_ds = random_split(dataset, [1300, 299])\n",
"batch_size=50\n",
"train_loader = DataLoader(train_ds, batch_size, shuffle=True)\n",
"val_loader = DataLoader(val_ds, batch_size)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "56f75067",
"metadata": {},
"outputs": [],
"source": [
"class WineQuality(nn.Module):\n",
" def __init__(self):\n",
" super().__init__()\n",
" self.linear = nn.Linear(input_size,output_size) \n",
" \n",
" def forward(self, xb): \n",
" out = self.linear(xb)\n",
" return out\n",
" \n",
" def training_step(self, batch):\n",
" inputs, targets = batch \n",
" # Generate predictions\n",
" out = self(inputs) \n",
" # Calcuate loss\n",
" loss = F.l1_loss(out,targets) \n",
" return loss\n",
" \n",
" def validation_step(self, batch):\n",
" inputs, targets = batch\n",
" # Generate predictions\n",
" out = self(inputs)\n",
" # Calculate loss\n",
" loss = F.l1_loss(out,targets) \n",
" return {'val_loss': loss.detach()}\n",
" \n",
" def validation_epoch_end(self, outputs):\n",
" batch_losses = [x['val_loss'] for x in outputs]\n",
" epoch_loss = torch.stack(batch_losses).mean() \n",
" return {'val_loss': epoch_loss.item()}\n",
" \n",
" def epoch_end(self, epoch, result, num_epochs):\n",
" # Print result every 100th epoch\n",
" if (epoch+1) % 100 == 0 or epoch == num_epochs-1:\n",
" print(\"Epoch [{}], val_loss: {:.4f}\".format(epoch+1, result['val_loss']))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "57f354ce",
"metadata": {},
"outputs": [],
"source": [
"input_size = len(input_cols)\n",
"output_size = len(output_cols)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "4a926cfa",
"metadata": {},
"outputs": [],
"source": [
"model=WineQuality()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "3df1733d",
"metadata": {},
"outputs": [],
"source": [
"def evaluate(model, val_loader):\n",
" outputs = [model.validation_step(batch) for batch in val_loader]\n",
" return model.validation_epoch_end(outputs)\n",
"\n",
"def fit(epochs, lr, model, train_loader, val_loader, opt_func=torch.optim.SGD):\n",
" history = []\n",
" optimizer = opt_func(model.parameters(), lr)\n",
" for epoch in range(epochs):\n",
" for batch in train_loader:\n",
" loss = model.training_step(batch)\n",
" loss.backward()\n",
" optimizer.step()\n",
" optimizer.zero_grad()\n",
" result = evaluate(model, val_loader)\n",
" model.epoch_end(epoch, result, epochs)\n",
" history.append(result)\n",
" return history"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "3ed5f872",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch [100], val_loss: 4.1732\n",
"Epoch [200], val_loss: 1.6444\n",
"Epoch [300], val_loss: 1.4860\n",
"Epoch [400], val_loss: 1.4119\n",
"Epoch [500], val_loss: 1.3407\n",
"Epoch [600], val_loss: 1.2709\n",
"Epoch [700], val_loss: 1.2045\n",
"Epoch [800], val_loss: 1.1401\n",
"Epoch [900], val_loss: 1.0783\n",
"Epoch [1000], val_loss: 1.0213\n",
"Epoch [1100], val_loss: 0.9678\n",
"Epoch [1200], val_loss: 0.9186\n",
"Epoch [1300], val_loss: 0.8729\n",
"Epoch [1400], val_loss: 0.8320\n",
"Epoch [1500], val_loss: 0.7959\n"
]
}
],
"source": [
"epochs = 1500\n",
"lr = 1e-6\n",
"history5 = fit(epochs, lr, model, train_loader, val_loader)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "413ab394",
"metadata": {},
"outputs": [],
"source": [
"def predict_single(input, target, model):\n",
" inputs = input.unsqueeze(0)\n",
" predictions = model(inputs)\n",
" prediction = predictions[0].detach()\n",
"\n",
" return \"Target: \"+str(target)+\"----- Prediction: \"+str(prediction)+\"\\n\""
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "b1ab4522",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Target: tensor([5.])----- Prediction: tensor([4.9765])\n",
"Target: tensor([5.])----- Prediction: tensor([6.6649])\n",
"Target: tensor([5.])----- Prediction: tensor([5.2627])\n",
"Target: tensor([7.])----- Prediction: tensor([5.7054])\n",
"Target: tensor([5.])----- Prediction: tensor([5.1168])\n",
"Target: tensor([7.])----- Prediction: tensor([5.3928])\n",
"Target: tensor([5.])----- Prediction: tensor([4.8501])\n",
"Target: tensor([4.])----- Prediction: tensor([5.4210])\n",
"Target: tensor([5.])----- Prediction: tensor([4.6719])\n",
"Target: tensor([5.])----- Prediction: tensor([7.8635])\n"
]
}
],
"source": [
"#wylosuj 10 próbek predykcji\n",
"for i in random.sample(range(0, len(val_ds)), 10):\n",
" input_, target = val_ds[i]\n",
" print(predict_single(input_, target, model),end=\"\")\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "a754aaff",
"metadata": {},
"outputs": [],
"source": [
"with open(\"result.txt\", \"w+\") as file:\n",
" for i in range(0, len(val_ds), 1):\n",
" input_, target = val_ds[i]\n",
" file.write(str(predict_single(input_, target, model)))"
]
}
],
"metadata": {
"kernelspec": {
"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.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

3
pytorch/.jovianrc Normal file
View File

@ -0,0 +1,3 @@
{
"notebooks": {}
}

33
pytorch/Dockerfile Normal file
View File

@ -0,0 +1,33 @@
FROM ubuntu:latest
# Install required dependencies
RUN apt update
RUN apt-get update
RUN apt install -y figlet
RUN export PATH=$PATH:/usr/local/bin/python”
RUN apt install python3-pip -y
RUN apt install unzip -y
RUN pip3 install --upgrade pip
RUN pip3 install --upgrade Pillow
RUN pip3 install pandas
RUN pip3 install scikit-learn
RUN pip3 install matplotlib
RUN pip3 install jovian
RUN pip3 install torch
RUN pip3 install seaborn
RUN pip3 install random
RUN pip3 install torchvision
# COPY ./script.sh ./
# RUN chmod a+x ./script.sh
# Create app directory in image
WORKDIR /app
COPY ./winequality-red.csv ./
# Copy init dataset script to /app directory in image
COPY ./pytorch.py ./
# Script executed after docker run
# CMD python3 ./pytorch.py
RUN chmod o+wrx ./runTrain.sh
RUN ./runTrain.sh

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 18,
"id": "e1c5e25d",
"metadata": {},
"outputs": [],
@ -18,7 +18,9 @@
"import torch.nn.functional as F\n",
"from torchvision.datasets.utils import download_url\n",
"from torch.utils.data import DataLoader, TensorDataset, random_split\n",
"import random"
"import random\n",
"import os\n",
"import sys"
]
},
{
@ -295,7 +297,7 @@
{
"data": {
"text/plain": [
"<torch.utils.data.dataset.TensorDataset at 0x16db5c32af0>"
"<torch.utils.data.dataset.TensorDataset at 0x1f334183760>"
]
},
"execution_count": 6,
@ -366,7 +368,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"id": "57f354ce",
"metadata": {},
"outputs": [],
@ -377,7 +379,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"id": "4a926cfa",
"metadata": {},
"outputs": [],
@ -387,7 +389,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"id": "3df1733d",
"metadata": {},
"outputs": [],
@ -413,7 +415,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"id": "3ed5f872",
"metadata": {},
"outputs": [
@ -421,21 +423,21 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch [100], val_loss: 5.1117\n",
"Epoch [200], val_loss: 1.7651\n",
"Epoch [300], val_loss: 1.4800\n",
"Epoch [400], val_loss: 1.3942\n",
"Epoch [500], val_loss: 1.3119\n",
"Epoch [600], val_loss: 1.2326\n",
"Epoch [700], val_loss: 1.1571\n",
"Epoch [800], val_loss: 1.0863\n",
"Epoch [900], val_loss: 1.0224\n",
"Epoch [1000], val_loss: 0.9642\n",
"Epoch [1100], val_loss: 0.9100\n",
"Epoch [1200], val_loss: 0.8617\n",
"Epoch [1300], val_loss: 0.8200\n",
"Epoch [1400], val_loss: 0.7816\n",
"Epoch [1500], val_loss: 0.7484\n"
"Epoch [100], val_loss: 4.1732\n",
"Epoch [200], val_loss: 1.6444\n",
"Epoch [300], val_loss: 1.4860\n",
"Epoch [400], val_loss: 1.4119\n",
"Epoch [500], val_loss: 1.3407\n",
"Epoch [600], val_loss: 1.2709\n",
"Epoch [700], val_loss: 1.2045\n",
"Epoch [800], val_loss: 1.1401\n",
"Epoch [900], val_loss: 1.0783\n",
"Epoch [1000], val_loss: 1.0213\n",
"Epoch [1100], val_loss: 0.9678\n",
"Epoch [1200], val_loss: 0.9186\n",
"Epoch [1300], val_loss: 0.8729\n",
"Epoch [1400], val_loss: 0.8320\n",
"Epoch [1500], val_loss: 0.7959\n"
]
}
],
@ -447,7 +449,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 27,
"id": "413ab394",
"metadata": {},
"outputs": [],
@ -456,15 +458,13 @@
" inputs = input.unsqueeze(0)\n",
" predictions = model(inputs)\n",
" prediction = predictions[0].detach()\n",
" #print(\"Input:\", input)\n",
" #print(\"Target:\", target)\n",
" #print(\"Prediction:\", prediction)\n",
" print(\"Target: \", target, \"----- Prediction: \", prediction)"
"\n",
" return \"Target: \"+str(target)+\"----- Prediction: \"+str(prediction)+\"\\n\""
]
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 32,
"id": "b1ab4522",
"metadata": {},
"outputs": [
@ -472,16 +472,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Target: tensor([6.]) ----- Prediction: tensor([5.1011])\n",
"Target: tensor([6.]) ----- Prediction: tensor([7.1398])\n",
"Target: tensor([5.]) ----- Prediction: tensor([5.1009])\n",
"Target: tensor([6.]) ----- Prediction: tensor([5.2282])\n",
"Target: tensor([5.]) ----- Prediction: tensor([4.8219])\n",
"Target: tensor([6.]) ----- Prediction: tensor([4.8082])\n",
"Target: tensor([7.]) ----- Prediction: tensor([5.0764])\n",
"Target: tensor([5.]) ----- Prediction: tensor([6.3668])\n",
"Target: tensor([6.]) ----- Prediction: tensor([5.0642])\n",
"Target: tensor([5.]) ----- Prediction: tensor([5.4656])\n"
"Target: tensor([5.])----- Prediction: tensor([4.9765])\n",
"Target: tensor([5.])----- Prediction: tensor([6.6649])\n",
"Target: tensor([5.])----- Prediction: tensor([5.2627])\n",
"Target: tensor([7.])----- Prediction: tensor([5.7054])\n",
"Target: tensor([5.])----- Prediction: tensor([5.1168])\n",
"Target: tensor([7.])----- Prediction: tensor([5.3928])\n",
"Target: tensor([5.])----- Prediction: tensor([4.8501])\n",
"Target: tensor([4.])----- Prediction: tensor([5.4210])\n",
"Target: tensor([5.])----- Prediction: tensor([4.6719])\n",
"Target: tensor([5.])----- Prediction: tensor([7.8635])\n"
]
}
],
@ -489,17 +489,22 @@
"#wylosuj 10 próbek predykcji\n",
"for i in random.sample(range(0, len(val_ds)), 10):\n",
" input_, target = val_ds[i]\n",
" predict_single(input_, target, model)\n",
" print(predict_single(input_, target, model),end=\"\")\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0237aad2",
"execution_count": 36,
"id": "a754aaff",
"metadata": {},
"outputs": [],
"source": []
"source": [
"with open(\"result.txt\", \"w+\") as file:\n",
" for i in range(0, len(val_ds), 1):\n",
" input_, target = val_ds[i]\n",
" file.write(str(predict_single(input_, target, model)))"
]
}
],
"metadata": {

187
pytorch/pytorch.py Normal file
View File

@ -0,0 +1,187 @@
#!/usr/bin/env python
# coding: utf-8
# In[18]:
import torch
import jovian
import torchvision
import matplotlib
import torch.nn as nn
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import torch.nn.functional as F
from torchvision.datasets.utils import download_url
from torch.utils.data import DataLoader, TensorDataset, random_split
import random
import os
import sys
# In[2]:
dataframe_raw = pd.read_csv("winequality-red.csv")
dataframe_raw.head()
# In[3]:
input_cols=list(dataframe_raw.columns)[:-1]
output_cols = ['quality']
input_cols,output_cols
# In[4]:
def dataframe_to_arrays(dataframe):
dataframe1 = dataframe_raw.copy(deep=True)
inputs_array = dataframe1[input_cols].to_numpy()
targets_array = dataframe1[output_cols].to_numpy()
return inputs_array, targets_array
inputs_array, targets_array = dataframe_to_arrays(dataframe_raw)
inputs_array, targets_array
# In[5]:
inputs = torch.from_numpy(inputs_array).type(torch.float)
targets = torch.from_numpy(targets_array).type(torch.float)
inputs,targets
# In[6]:
dataset = TensorDataset(inputs, targets)
dataset
# In[7]:
train_ds, val_ds = random_split(dataset, [1300, 299])
batch_size=50
train_loader = DataLoader(train_ds, batch_size, shuffle=True)
val_loader = DataLoader(val_ds, batch_size)
# In[8]:
class WineQuality(nn.Module):
def __init__(self):
super().__init__()
self.linear = nn.Linear(input_size,output_size)
def forward(self, xb):
out = self.linear(xb)
return out
def training_step(self, batch):
inputs, targets = batch
# Generate predictions
out = self(inputs)
# Calcuate loss
loss = F.l1_loss(out,targets)
return loss
def validation_step(self, batch):
inputs, targets = batch
# Generate predictions
out = self(inputs)
# Calculate loss
loss = F.l1_loss(out,targets)
return {'val_loss': loss.detach()}
def validation_epoch_end(self, outputs):
batch_losses = [x['val_loss'] for x in outputs]
epoch_loss = torch.stack(batch_losses).mean()
return {'val_loss': epoch_loss.item()}
def epoch_end(self, epoch, result, num_epochs):
# Print result every 100th epoch
if (epoch+1) % 100 == 0 or epoch == num_epochs-1:
print("Epoch [{}], val_loss: {:.4f}".format(epoch+1, result['val_loss']))
# In[9]:
input_size = len(input_cols)
output_size = len(output_cols)
# In[10]:
model=WineQuality()
# In[11]:
def evaluate(model, val_loader):
outputs = [model.validation_step(batch) for batch in val_loader]
return model.validation_epoch_end(outputs)
def fit(epochs, lr, model, train_loader, val_loader, opt_func=torch.optim.SGD):
history = []
optimizer = opt_func(model.parameters(), lr)
for epoch in range(epochs):
for batch in train_loader:
loss = model.training_step(batch)
loss.backward()
optimizer.step()
optimizer.zero_grad()
result = evaluate(model, val_loader)
model.epoch_end(epoch, result, epochs)
history.append(result)
return history
# In[12]:
epochs = 1500
lr = 1e-6
history5 = fit(epochs, lr, model, train_loader, val_loader)
# In[27]:
def predict_single(input, target, model):
inputs = input.unsqueeze(0)
predictions = model(inputs)
prediction = predictions[0].detach()
return "Target: "+str(target)+"----- Prediction: "+str(prediction)+"\n"
# In[32]:
#wylosuj 10 próbek predykcji
for i in random.sample(range(0, len(val_ds)), 10):
input_, target = val_ds[i]
print(predict_single(input_, target, model),end="")
# In[36]:
with open("result.txt", "w+") as file:
for i in range(0, len(val_ds), 1):
input_, target = val_ds[i]
file.write(str(predict_single(input_, target, model)))

299
pytorch/result.txt Normal file
View File

@ -0,0 +1,299 @@
Target: tensor([4.])----- Prediction: tensor([2.5912])
Target: tensor([7.])----- Prediction: tensor([5.3811])
Target: tensor([6.])----- Prediction: tensor([2.4516])
Target: tensor([5.])----- Prediction: tensor([6.6527])
Target: tensor([5.])----- Prediction: tensor([3.6947])
Target: tensor([7.])----- Prediction: tensor([3.0992])
Target: tensor([5.])----- Prediction: tensor([3.5280])
Target: tensor([6.])----- Prediction: tensor([2.8694])
Target: tensor([5.])----- Prediction: tensor([10.5723])
Target: tensor([6.])----- Prediction: tensor([1.5417])
Target: tensor([6.])----- Prediction: tensor([1.5702])
Target: tensor([6.])----- Prediction: tensor([3.8206])
Target: tensor([6.])----- Prediction: tensor([5.5910])
Target: tensor([7.])----- Prediction: tensor([2.1009])
Target: tensor([5.])----- Prediction: tensor([1.9532])
Target: tensor([6.])----- Prediction: tensor([5.4789])
Target: tensor([5.])----- Prediction: tensor([3.4121])
Target: tensor([6.])----- Prediction: tensor([5.6153])
Target: tensor([6.])----- Prediction: tensor([2.7008])
Target: tensor([6.])----- Prediction: tensor([2.4302])
Target: tensor([5.])----- Prediction: tensor([11.2693])
Target: tensor([7.])----- Prediction: tensor([2.9486])
Target: tensor([6.])----- Prediction: tensor([2.0228])
Target: tensor([5.])----- Prediction: tensor([5.8602])
Target: tensor([5.])----- Prediction: tensor([3.8908])
Target: tensor([6.])----- Prediction: tensor([10.1888])
Target: tensor([5.])----- Prediction: tensor([6.6399])
Target: tensor([6.])----- Prediction: tensor([3.7961])
Target: tensor([6.])----- Prediction: tensor([3.8239])
Target: tensor([5.])----- Prediction: tensor([3.6467])
Target: tensor([6.])----- Prediction: tensor([5.6153])
Target: tensor([5.])----- Prediction: tensor([4.1886])
Target: tensor([6.])----- Prediction: tensor([7.4703])
Target: tensor([5.])----- Prediction: tensor([6.7674])
Target: tensor([6.])----- Prediction: tensor([3.9402])
Target: tensor([5.])----- Prediction: tensor([10.8020])
Target: tensor([5.])----- Prediction: tensor([3.7203])
Target: tensor([6.])----- Prediction: tensor([4.3365])
Target: tensor([6.])----- Prediction: tensor([4.0502])
Target: tensor([5.])----- Prediction: tensor([5.1851])
Target: tensor([7.])----- Prediction: tensor([3.8488])
Target: tensor([5.])----- Prediction: tensor([2.4501])
Target: tensor([6.])----- Prediction: tensor([2.9132])
Target: tensor([7.])----- Prediction: tensor([3.3335])
Target: tensor([5.])----- Prediction: tensor([7.8335])
Target: tensor([6.])----- Prediction: tensor([2.5696])
Target: tensor([6.])----- Prediction: tensor([2.7571])
Target: tensor([6.])----- Prediction: tensor([5.0917])
Target: tensor([5.])----- Prediction: tensor([12.2102])
Target: tensor([5.])----- Prediction: tensor([7.3395])
Target: tensor([6.])----- Prediction: tensor([2.2568])
Target: tensor([7.])----- Prediction: tensor([3.2961])
Target: tensor([5.])----- Prediction: tensor([1.6766])
Target: tensor([5.])----- Prediction: tensor([3.5993])
Target: tensor([6.])----- Prediction: tensor([5.0940])
Target: tensor([5.])----- Prediction: tensor([9.0951])
Target: tensor([6.])----- Prediction: tensor([3.0024])
Target: tensor([5.])----- Prediction: tensor([3.1072])
Target: tensor([7.])----- Prediction: tensor([7.0583])
Target: tensor([5.])----- Prediction: tensor([3.1533])
Target: tensor([5.])----- Prediction: tensor([11.8913])
Target: tensor([5.])----- Prediction: tensor([1.7950])
Target: tensor([6.])----- Prediction: tensor([3.5572])
Target: tensor([6.])----- Prediction: tensor([2.9728])
Target: tensor([7.])----- Prediction: tensor([2.1861])
Target: tensor([6.])----- Prediction: tensor([3.7599])
Target: tensor([6.])----- Prediction: tensor([4.5269])
Target: tensor([6.])----- Prediction: tensor([3.1787])
Target: tensor([7.])----- Prediction: tensor([2.6388])
Target: tensor([5.])----- Prediction: tensor([6.9238])
Target: tensor([7.])----- Prediction: tensor([4.8372])
Target: tensor([6.])----- Prediction: tensor([4.9583])
Target: tensor([5.])----- Prediction: tensor([2.8367])
Target: tensor([5.])----- Prediction: tensor([3.2148])
Target: tensor([5.])----- Prediction: tensor([2.2810])
Target: tensor([5.])----- Prediction: tensor([5.5056])
Target: tensor([6.])----- Prediction: tensor([1.5980])
Target: tensor([6.])----- Prediction: tensor([3.2662])
Target: tensor([6.])----- Prediction: tensor([2.0195])
Target: tensor([5.])----- Prediction: tensor([10.5990])
Target: tensor([7.])----- Prediction: tensor([2.8631])
Target: tensor([5.])----- Prediction: tensor([8.1595])
Target: tensor([6.])----- Prediction: tensor([3.9324])
Target: tensor([6.])----- Prediction: tensor([3.2511])
Target: tensor([6.])----- Prediction: tensor([3.6911])
Target: tensor([5.])----- Prediction: tensor([3.7448])
Target: tensor([4.])----- Prediction: tensor([1.5203])
Target: tensor([6.])----- Prediction: tensor([3.9098])
Target: tensor([5.])----- Prediction: tensor([3.7416])
Target: tensor([7.])----- Prediction: tensor([2.1332])
Target: tensor([6.])----- Prediction: tensor([6.7936])
Target: tensor([5.])----- Prediction: tensor([5.2619])
Target: tensor([5.])----- Prediction: tensor([2.4828])
Target: tensor([6.])----- Prediction: tensor([2.9184])
Target: tensor([7.])----- Prediction: tensor([3.9367])
Target: tensor([6.])----- Prediction: tensor([4.4000])
Target: tensor([5.])----- Prediction: tensor([4.0671])
Target: tensor([8.])----- Prediction: tensor([8.0165])
Target: tensor([5.])----- Prediction: tensor([4.5995])
Target: tensor([6.])----- Prediction: tensor([7.7532])
Target: tensor([5.])----- Prediction: tensor([9.6909])
Target: tensor([5.])----- Prediction: tensor([5.7997])
Target: tensor([6.])----- Prediction: tensor([8.8374])
Target: tensor([6.])----- Prediction: tensor([4.0067])
Target: tensor([5.])----- Prediction: tensor([10.5642])
Target: tensor([5.])----- Prediction: tensor([2.3271])
Target: tensor([5.])----- Prediction: tensor([2.0700])
Target: tensor([6.])----- Prediction: tensor([1.7528])
Target: tensor([6.])----- Prediction: tensor([5.2573])
Target: tensor([7.])----- Prediction: tensor([3.1217])
Target: tensor([5.])----- Prediction: tensor([3.4221])
Target: tensor([4.])----- Prediction: tensor([2.1967])
Target: tensor([6.])----- Prediction: tensor([1.8576])
Target: tensor([5.])----- Prediction: tensor([3.9776])
Target: tensor([4.])----- Prediction: tensor([1.8588])
Target: tensor([7.])----- Prediction: tensor([8.4651])
Target: tensor([5.])----- Prediction: tensor([3.0248])
Target: tensor([5.])----- Prediction: tensor([9.5106])
Target: tensor([6.])----- Prediction: tensor([2.3674])
Target: tensor([7.])----- Prediction: tensor([7.9203])
Target: tensor([6.])----- Prediction: tensor([5.6564])
Target: tensor([5.])----- Prediction: tensor([4.9836])
Target: tensor([6.])----- Prediction: tensor([3.6858])
Target: tensor([6.])----- Prediction: tensor([4.3583])
Target: tensor([7.])----- Prediction: tensor([2.9855])
Target: tensor([5.])----- Prediction: tensor([7.3182])
Target: tensor([5.])----- Prediction: tensor([7.9802])
Target: tensor([5.])----- Prediction: tensor([2.2287])
Target: tensor([6.])----- Prediction: tensor([3.9656])
Target: tensor([5.])----- Prediction: tensor([2.4347])
Target: tensor([6.])----- Prediction: tensor([5.8240])
Target: tensor([5.])----- Prediction: tensor([2.6369])
Target: tensor([7.])----- Prediction: tensor([1.8155])
Target: tensor([5.])----- Prediction: tensor([10.1038])
Target: tensor([5.])----- Prediction: tensor([2.3575])
Target: tensor([5.])----- Prediction: tensor([3.9901])
Target: tensor([5.])----- Prediction: tensor([2.4601])
Target: tensor([6.])----- Prediction: tensor([2.8243])
Target: tensor([5.])----- Prediction: tensor([7.7295])
Target: tensor([5.])----- Prediction: tensor([3.4800])
Target: tensor([6.])----- Prediction: tensor([2.6094])
Target: tensor([6.])----- Prediction: tensor([2.6338])
Target: tensor([6.])----- Prediction: tensor([3.7549])
Target: tensor([6.])----- Prediction: tensor([3.0682])
Target: tensor([7.])----- Prediction: tensor([23.9401])
Target: tensor([7.])----- Prediction: tensor([2.9943])
Target: tensor([6.])----- Prediction: tensor([5.7540])
Target: tensor([7.])----- Prediction: tensor([3.5938])
Target: tensor([6.])----- Prediction: tensor([3.8617])
Target: tensor([6.])----- Prediction: tensor([4.4898])
Target: tensor([6.])----- Prediction: tensor([4.1527])
Target: tensor([6.])----- Prediction: tensor([13.8834])
Target: tensor([5.])----- Prediction: tensor([3.4153])
Target: tensor([5.])----- Prediction: tensor([10.9910])
Target: tensor([6.])----- Prediction: tensor([3.2680])
Target: tensor([5.])----- Prediction: tensor([2.7166])
Target: tensor([6.])----- Prediction: tensor([2.7429])
Target: tensor([6.])----- Prediction: tensor([1.8801])
Target: tensor([5.])----- Prediction: tensor([4.7673])
Target: tensor([6.])----- Prediction: tensor([2.3313])
Target: tensor([5.])----- Prediction: tensor([8.0485])
Target: tensor([5.])----- Prediction: tensor([2.2194])
Target: tensor([7.])----- Prediction: tensor([4.6185])
Target: tensor([6.])----- Prediction: tensor([3.9581])
Target: tensor([6.])----- Prediction: tensor([3.2511])
Target: tensor([5.])----- Prediction: tensor([9.4976])
Target: tensor([5.])----- Prediction: tensor([2.8048])
Target: tensor([7.])----- Prediction: tensor([2.3068])
Target: tensor([5.])----- Prediction: tensor([5.2228])
Target: tensor([5.])----- Prediction: tensor([3.4355])
Target: tensor([6.])----- Prediction: tensor([5.8229])
Target: tensor([6.])----- Prediction: tensor([4.9710])
Target: tensor([7.])----- Prediction: tensor([4.0948])
Target: tensor([5.])----- Prediction: tensor([9.8520])
Target: tensor([6.])----- Prediction: tensor([1.6064])
Target: tensor([7.])----- Prediction: tensor([4.0091])
Target: tensor([6.])----- Prediction: tensor([2.1055])
Target: tensor([5.])----- Prediction: tensor([5.5266])
Target: tensor([5.])----- Prediction: tensor([1.5365])
Target: tensor([5.])----- Prediction: tensor([2.0232])
Target: tensor([6.])----- Prediction: tensor([4.7462])
Target: tensor([8.])----- Prediction: tensor([3.0388])
Target: tensor([6.])----- Prediction: tensor([7.3761])
Target: tensor([8.])----- Prediction: tensor([4.0455])
Target: tensor([7.])----- Prediction: tensor([8.4651])
Target: tensor([7.])----- Prediction: tensor([2.2083])
Target: tensor([5.])----- Prediction: tensor([13.7213])
Target: tensor([6.])----- Prediction: tensor([2.4370])
Target: tensor([5.])----- Prediction: tensor([4.2159])
Target: tensor([6.])----- Prediction: tensor([3.0294])
Target: tensor([5.])----- Prediction: tensor([11.3286])
Target: tensor([4.])----- Prediction: tensor([3.1563])
Target: tensor([5.])----- Prediction: tensor([3.0204])
Target: tensor([6.])----- Prediction: tensor([3.1787])
Target: tensor([5.])----- Prediction: tensor([3.4895])
Target: tensor([5.])----- Prediction: tensor([3.9059])
Target: tensor([7.])----- Prediction: tensor([2.2940])
Target: tensor([5.])----- Prediction: tensor([6.0839])
Target: tensor([6.])----- Prediction: tensor([3.4874])
Target: tensor([5.])----- Prediction: tensor([12.2298])
Target: tensor([6.])----- Prediction: tensor([1.9277])
Target: tensor([5.])----- Prediction: tensor([4.9739])
Target: tensor([7.])----- Prediction: tensor([4.5098])
Target: tensor([5.])----- Prediction: tensor([3.4803])
Target: tensor([6.])----- Prediction: tensor([2.3278])
Target: tensor([6.])----- Prediction: tensor([8.8388])
Target: tensor([7.])----- Prediction: tensor([2.6388])
Target: tensor([7.])----- Prediction: tensor([1.8263])
Target: tensor([5.])----- Prediction: tensor([1.7058])
Target: tensor([5.])----- Prediction: tensor([4.7320])
Target: tensor([5.])----- Prediction: tensor([7.0629])
Target: tensor([8.])----- Prediction: tensor([6.6816])
Target: tensor([6.])----- Prediction: tensor([2.3679])
Target: tensor([5.])----- Prediction: tensor([6.4106])
Target: tensor([5.])----- Prediction: tensor([12.3476])
Target: tensor([6.])----- Prediction: tensor([3.1205])
Target: tensor([6.])----- Prediction: tensor([2.6261])
Target: tensor([5.])----- Prediction: tensor([2.4900])
Target: tensor([6.])----- Prediction: tensor([3.5584])
Target: tensor([5.])----- Prediction: tensor([4.1916])
Target: tensor([5.])----- Prediction: tensor([5.9044])
Target: tensor([6.])----- Prediction: tensor([5.7723])
Target: tensor([6.])----- Prediction: tensor([6.3909])
Target: tensor([5.])----- Prediction: tensor([4.7932])
Target: tensor([5.])----- Prediction: tensor([4.7548])
Target: tensor([5.])----- Prediction: tensor([8.0386])
Target: tensor([5.])----- Prediction: tensor([5.5603])
Target: tensor([3.])----- Prediction: tensor([5.2508])
Target: tensor([5.])----- Prediction: tensor([3.8790])
Target: tensor([6.])----- Prediction: tensor([2.0702])
Target: tensor([5.])----- Prediction: tensor([2.0624])
Target: tensor([5.])----- Prediction: tensor([8.8042])
Target: tensor([6.])----- Prediction: tensor([3.9469])
Target: tensor([7.])----- Prediction: tensor([4.1208])
Target: tensor([7.])----- Prediction: tensor([3.2084])
Target: tensor([6.])----- Prediction: tensor([2.2332])
Target: tensor([4.])----- Prediction: tensor([4.9973])
Target: tensor([5.])----- Prediction: tensor([3.9620])
Target: tensor([6.])----- Prediction: tensor([1.6706])
Target: tensor([5.])----- Prediction: tensor([6.3914])
Target: tensor([6.])----- Prediction: tensor([3.2084])
Target: tensor([6.])----- Prediction: tensor([5.7970])
Target: tensor([7.])----- Prediction: tensor([3.4445])
Target: tensor([5.])----- Prediction: tensor([8.4952])
Target: tensor([5.])----- Prediction: tensor([2.4870])
Target: tensor([5.])----- Prediction: tensor([3.4096])
Target: tensor([6.])----- Prediction: tensor([8.2855])
Target: tensor([6.])----- Prediction: tensor([1.8462])
Target: tensor([4.])----- Prediction: tensor([4.3964])
Target: tensor([6.])----- Prediction: tensor([3.4177])
Target: tensor([5.])----- Prediction: tensor([3.5993])
Target: tensor([6.])----- Prediction: tensor([2.0421])
Target: tensor([5.])----- Prediction: tensor([8.7133])
Target: tensor([5.])----- Prediction: tensor([10.1540])
Target: tensor([7.])----- Prediction: tensor([2.3574])
Target: tensor([7.])----- Prediction: tensor([3.2022])
Target: tensor([5.])----- Prediction: tensor([1.6709])
Target: tensor([3.])----- Prediction: tensor([4.6296])
Target: tensor([5.])----- Prediction: tensor([7.6198])
Target: tensor([5.])----- Prediction: tensor([2.4627])
Target: tensor([5.])----- Prediction: tensor([8.2276])
Target: tensor([4.])----- Prediction: tensor([2.4551])
Target: tensor([6.])----- Prediction: tensor([2.6208])
Target: tensor([7.])----- Prediction: tensor([3.0895])
Target: tensor([4.])----- Prediction: tensor([3.6925])
Target: tensor([5.])----- Prediction: tensor([3.2303])
Target: tensor([6.])----- Prediction: tensor([4.6480])
Target: tensor([5.])----- Prediction: tensor([6.2549])
Target: tensor([5.])----- Prediction: tensor([3.6234])
Target: tensor([6.])----- Prediction: tensor([3.1382])
Target: tensor([5.])----- Prediction: tensor([2.3479])
Target: tensor([5.])----- Prediction: tensor([5.1068])
Target: tensor([7.])----- Prediction: tensor([2.4958])
Target: tensor([6.])----- Prediction: tensor([1.8829])
Target: tensor([6.])----- Prediction: tensor([6.7703])
Target: tensor([7.])----- Prediction: tensor([3.2449])
Target: tensor([5.])----- Prediction: tensor([5.7864])
Target: tensor([6.])----- Prediction: tensor([2.5621])
Target: tensor([5.])----- Prediction: tensor([3.1336])
Target: tensor([6.])----- Prediction: tensor([2.8112])
Target: tensor([5.])----- Prediction: tensor([7.0639])
Target: tensor([5.])----- Prediction: tensor([8.0485])
Target: tensor([6.])----- Prediction: tensor([4.8817])
Target: tensor([5.])----- Prediction: tensor([1.4661])
Target: tensor([5.])----- Prediction: tensor([4.0572])
Target: tensor([6.])----- Prediction: tensor([2.6261])
Target: tensor([5.])----- Prediction: tensor([6.3413])
Target: tensor([5.])----- Prediction: tensor([10.9089])
Target: tensor([5.])----- Prediction: tensor([2.8428])
Target: tensor([6.])----- Prediction: tensor([2.0931])
Target: tensor([5.])----- Prediction: tensor([9.9907])
Target: tensor([6.])----- Prediction: tensor([5.4379])
Target: tensor([6.])----- Prediction: tensor([2.5430])
Target: tensor([5.])----- Prediction: tensor([6.8091])
Target: tensor([5.])----- Prediction: tensor([3.3554])
Target: tensor([5.])----- Prediction: tensor([7.0773])
Target: tensor([6.])----- Prediction: tensor([3.1898])
Target: tensor([6.])----- Prediction: tensor([8.0325])
Target: tensor([6.])----- Prediction: tensor([4.2776])

1600
pytorch/winequality-red.csv Normal file

File diff suppressed because it is too large Load Diff

2
runTrain.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/bash
python3 ./pytorch.py