going to pytorch on conda eve
This commit is contained in:
parent
239eaf7d97
commit
4720da3158
@ -3,5 +3,5 @@
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (AL-2020)" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -20,9 +20,10 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="828778c9-9d97-422f-a727-18ddbd059b85" name="Default Changelist" comment="po">
|
||||
<change afterPath="$PROJECT_DIR$/coder/dataset/test.csv" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/coder/dataset/train.csv" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/coder/digits_recognizer.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/wozek.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/wozek.iml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/coder/image.py" beforeDir="false" afterPath="$PROJECT_DIR$/coder/image.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -82,7 +83,7 @@
|
||||
<recent name="C:\Users\Pawel Lukaszewicz\PycharmProjects\AL-2020\coder" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Python.image">
|
||||
<component name="RunManager" selected="Python.digits_recognizer">
|
||||
<configuration default="true" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="wozek" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
@ -105,22 +106,19 @@
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="feature_hashing" type="PythonConfigurationType" factoryName="Python" temporary="true">
|
||||
<configuration name="digits_recognizer" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="wozek" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Assiging" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/coder" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/Assiging/feature_hashing.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/coder/digits_recognizer.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="SHOW_COMMAND_LINE" value="true" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
@ -131,6 +129,9 @@
|
||||
<module name="wozek" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/coder" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
@ -215,17 +216,17 @@
|
||||
<list>
|
||||
<item itemvalue="Python.image" />
|
||||
<item itemvalue="Python.main" />
|
||||
<item itemvalue="Python.feature_hashing" />
|
||||
<item itemvalue="Python.train_nn" />
|
||||
<item itemvalue="Python.rocognizer" />
|
||||
<item itemvalue="Python.digits_recognizer" />
|
||||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.digits_recognizer" />
|
||||
<item itemvalue="Python.image" />
|
||||
<item itemvalue="Python.rocognizer" />
|
||||
<item itemvalue="Python.train_nn" />
|
||||
<item itemvalue="Python.main" />
|
||||
<item itemvalue="Python.feature_hashing" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
@ -257,6 +258,11 @@
|
||||
<workItem from="1590230578314" duration="1895000" />
|
||||
<workItem from="1590235510565" duration="925000" />
|
||||
<workItem from="1590340739871" duration="8052000" />
|
||||
<workItem from="1590359007619" duration="127000" />
|
||||
<workItem from="1590409526059" duration="4922000" />
|
||||
<workItem from="1590423569728" duration="2532000" />
|
||||
<workItem from="1590436739719" duration="6325000" />
|
||||
<workItem from="1590443664804" duration="2683000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="create Shelf">
|
||||
<created>1589815443652</created>
|
||||
@ -328,7 +334,14 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1589972251988</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="11" />
|
||||
<task id="LOCAL-00011" summary="new dataset">
|
||||
<created>1590359074952</created>
|
||||
<option name="number" value="00011" />
|
||||
<option name="presentableId" value="LOCAL-00011" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1590359074952</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="12" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@ -358,7 +371,8 @@
|
||||
<MESSAGE value="zwiekszenie dokladnosci" />
|
||||
<MESSAGE value="finding barcode" />
|
||||
<MESSAGE value="po" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="po" />
|
||||
<MESSAGE value="new dataset" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="new dataset" />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state x="115" y="162" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1589923610328">
|
||||
@ -381,14 +395,14 @@
|
||||
<screen x="0" y="0" width="1536" height="824" />
|
||||
</state>
|
||||
<state width="1493" height="208" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1589845242796" />
|
||||
<state x="277" y="57" key="SettingsEditor" timestamp="1589845139218">
|
||||
<state x="277" y="57" key="SettingsEditor" timestamp="1590443566792">
|
||||
<screen x="0" y="0" width="1536" height="824" />
|
||||
</state>
|
||||
<state x="277" y="57" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1589845139218" />
|
||||
<state x="361" y="145" key="Vcs.Push.Dialog.v2" timestamp="1589972275899">
|
||||
<state x="277" y="57" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1590443566792" />
|
||||
<state x="361" y="145" key="Vcs.Push.Dialog.v2" timestamp="1590359093497">
|
||||
<screen x="0" y="0" width="1536" height="824" />
|
||||
</state>
|
||||
<state x="361" y="145" key="Vcs.Push.Dialog.v2/0.0.1536.824@0.0.1536.824" timestamp="1589972275899" />
|
||||
<state x="361" y="145" key="Vcs.Push.Dialog.v2/0.0.1536.824@0.0.1536.824" timestamp="1590359093496" />
|
||||
<state x="54" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1589918982407">
|
||||
<screen x="0" y="0" width="1536" height="824" />
|
||||
</state>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.8" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.8 (AL-2020)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
|
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/processed/test.pt
Normal file
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/processed/test.pt
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/processed/training.pt
Normal file
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/processed/training.pt
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/t10k-images-idx3-ubyte
Normal file
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/t10k-images-idx3-ubyte
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/t10k-images-idx3-ubyte.gz
Normal file
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/t10k-images-idx3-ubyte.gz
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/t10k-labels-idx1-ubyte
Normal file
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/t10k-labels-idx1-ubyte
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/t10k-labels-idx1-ubyte.gz
Normal file
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/t10k-labels-idx1-ubyte.gz
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/train-images-idx3-ubyte
Normal file
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/train-images-idx3-ubyte
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/train-images-idx3-ubyte.gz
Normal file
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/train-images-idx3-ubyte.gz
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/train-labels-idx1-ubyte
Normal file
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/train-labels-idx1-ubyte
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/train-labels-idx1-ubyte.gz
Normal file
BIN
coder/PATH_TO_STORE_TESTSET/MNIST/raw/train-labels-idx1-ubyte.gz
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/processed/test.pt
Normal file
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/processed/test.pt
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/processed/training.pt
Normal file
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/processed/training.pt
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/t10k-images-idx3-ubyte
Normal file
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/t10k-images-idx3-ubyte
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/t10k-images-idx3-ubyte.gz
Normal file
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/t10k-images-idx3-ubyte.gz
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/t10k-labels-idx1-ubyte
Normal file
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/t10k-labels-idx1-ubyte
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/t10k-labels-idx1-ubyte.gz
Normal file
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/t10k-labels-idx1-ubyte.gz
Normal file
Binary file not shown.
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/train-images-idx3-ubyte
Normal file
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/train-images-idx3-ubyte
Normal file
Binary file not shown.
Binary file not shown.
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/train-labels-idx1-ubyte
Normal file
BIN
coder/PATH_TO_STORE_TRAINSET/MNIST/raw/train-labels-idx1-ubyte
Normal file
Binary file not shown.
Binary file not shown.
39
coder/digits_recognizer.py
Normal file
39
coder/digits_recognizer.py
Normal file
@ -0,0 +1,39 @@
|
||||
import numpy as np
|
||||
import torch
|
||||
import torchvision
|
||||
import matplotlib.pyplot as plt
|
||||
from time import time
|
||||
from torchvision import datasets, transforms
|
||||
from torch import nn, optim
|
||||
|
||||
transform = transforms.Compose([transforms.ToTensor(),
|
||||
transforms.Normalize((0.5,), (0.5,)),
|
||||
])
|
||||
|
||||
trainset = datasets.MNIST('PATH_TO_STORE_TRAINSET', download=True, train=True, transform=transform)
|
||||
valset = datasets.MNIST('PATH_TO_STORE_TESTSET', download=True, train=False, transform=transform)
|
||||
trainloader = torch.utils.data.DataLoader(trainset, batch_size=64, shuffle=True)
|
||||
valloader = torch.utils.data.DataLoader(valset, batch_size=64, shuffle=True)
|
||||
|
||||
dataiter = iter(trainloader)
|
||||
images, labels = dataiter.next()
|
||||
|
||||
print(images.shape)
|
||||
print(labels.shape)
|
||||
|
||||
plt.imshow(images[0].numpy().squeeze(), cmap='gray_r')
|
||||
plt.show()
|
||||
|
||||
# building nn model
|
||||
input_size = 784
|
||||
hidden_sizes = [128, 64]
|
||||
output_size = 10
|
||||
|
||||
model = nn.Sequential(nn.Linear(input_size, hidden_sizes[0]),
|
||||
nn.ReLU(),
|
||||
nn.Linear(hidden_sizes[0], hidden_sizes[1]),
|
||||
nn.ReLU(),
|
||||
nn.Linear(hidden_sizes[1], output_size),
|
||||
nn.LogSoftmax(dim=1))
|
||||
print(model)
|
||||
|
@ -7,11 +7,12 @@ from sklearn.neural_network import MLPClassifier
|
||||
import pandas as pd
|
||||
import cv2
|
||||
|
||||
#28x28
|
||||
train_data = np.genfromtxt('dataset/train.csv', delimiter=',', skip_header=1 ,max_rows=20000, encoding='utf-8')
|
||||
test_data = np.genfromtxt('dataset/test.csv', delimiter=',' , skip_header=1, max_rows=20000, encoding='utf-8')
|
||||
|
||||
# 28x28
|
||||
train_data = np.genfromtxt('dataset/train.csv', delimiter=',', skip_header=1, max_rows=20000, encoding='utf-8')
|
||||
test_data = np.genfromtxt('dataset/test.csv', delimiter=',', skip_header=1, max_rows=20000, encoding='utf-8')
|
||||
|
||||
# train_data = pd.read_csv('dataset/train.csv')
|
||||
# test_data = pd.read_csv('dataset/test.csv')
|
||||
|
||||
# training
|
||||
# recznie napisane cyfry
|
||||
@ -20,33 +21,35 @@ digits = datasets.load_digits()
|
||||
y = digits.target
|
||||
x = digits.images.reshape((len(digits.images), -1))
|
||||
|
||||
# print(type(y[0]), type(x[0]))
|
||||
# ogarnac zbior, zwiekszyc warstwy
|
||||
|
||||
#ogarnac zbior, zwiekszyc warstwy
|
||||
# x_train = train_data.iloc[:, 1:].values.astype('float32')
|
||||
# y_train = train_data.iloc[:, 0].values.astype('int32')
|
||||
# x_test = test_data.values.astype('float32')
|
||||
|
||||
x_train = train_data[0:20000, 1:]
|
||||
y_train = train_data[0:20000, 0]
|
||||
x_test = test_data[0:20000]
|
||||
y_test = test_data[0:20000, 0]
|
||||
x_train = train_data[0:10000, 1:]
|
||||
y_train = train_data[0:10000, 0]
|
||||
x_test = train_data[10001:20000, 1:]
|
||||
y_test = train_data[10001:20000, 0].astype('int')
|
||||
|
||||
print(type(y_test[0]), type(x_test[0]))
|
||||
|
||||
# x_train = x[:900]
|
||||
# y_train = y[:900]
|
||||
# x_test = x[900:]
|
||||
# y_test = y[900:]
|
||||
|
||||
print(x_test[0].shape, y_test[9].shape)
|
||||
|
||||
mlp = MLPClassifier(hidden_layer_sizes=(100, 100, 100, 100), activation='logistic', alpha=1e-4,
|
||||
# 500, 500, 500, 500, 500
|
||||
mlp = MLPClassifier(hidden_layer_sizes=(150, 100, 100, 100), activation='logistic', alpha=1e-4,
|
||||
solver='sgd', tol=0.000000000001, random_state=1,
|
||||
learning_rate_init=.1, verbose=True, max_iter=1000)
|
||||
learning_rate_init=.1, verbose=True, max_iter=10000)
|
||||
|
||||
mlp.fit(x_train, y_train)
|
||||
print(123456789)
|
||||
predictions = mlp.predict(x_test)
|
||||
print(123456789)
|
||||
|
||||
print("Accuracy: ", accuracy_score(y_test, predictions))
|
||||
|
||||
|
||||
# image
|
||||
|
||||
img = cv2.cvtColor(cv2.imread('test5.jpg'), cv2.COLOR_BGR2GRAY)
|
||||
@ -54,11 +57,10 @@ img = cv2.blur(img, (9, 9)) # poprawia jakosc
|
||||
img = cv2.resize(img, (28, 28), interpolation=cv2.INTER_AREA)
|
||||
img = img.reshape((len(img), -1))
|
||||
|
||||
print(type(img))
|
||||
print(img.shape)
|
||||
print(img)
|
||||
plt.imshow(img ,cmap='binary')
|
||||
plt.show()
|
||||
# print(type(img))
|
||||
# print(img.shape)
|
||||
# plt.imshow(img ,cmap='binary')
|
||||
# plt.show()
|
||||
|
||||
data = []
|
||||
|
||||
@ -69,13 +71,14 @@ for i in range(rows):
|
||||
if k > 225:
|
||||
k = 0 # brak czarnego
|
||||
else:
|
||||
k = 1
|
||||
k = 255
|
||||
|
||||
data.append(k)
|
||||
|
||||
data = np.asarray(data, dtype=np.float32)
|
||||
print(data)
|
||||
data = np.asarray(data, dtype=np.float64)
|
||||
# print(data)
|
||||
print(type(data))
|
||||
|
||||
predictions = mlp.predict([data])
|
||||
|
||||
print("Liczba to:", predictions[0])
|
||||
print("Liczba to:", predictions[0].astype('int'))
|
||||
|
Loading…
Reference in New Issue
Block a user