Fan: Boshqaruv tamoyillari Amaliy mashg’ulot Guruh



Yüklə 80,96 Kb.
səhifə1/2
tarix31.12.2021
ölçüsü80,96 Kb.
#81644
  1   2
mo`
O\'zbekistonda talim tizimi islohotlar 0
    Bu səhifədəki naviqasiya:
  • Guruh

O'ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI MUHAMMAD AL-XORAZMIYNOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

Kafedra:Marketing va menejment

Fan: Boshqaruv tamoyillari

Amaliy mashg’ulot


Guruh: 712-19

Bajardi:Yo`ldoshev Xushnudbek

Tekshirdi:Ochilov Mannon

import os

import json


import numpy as np

import pandas as pd

import keras

from keras.callbacks import Callback

from keras.datasets import cifar10

from keras.preprocessing.image import ImageDataGenerator

from keras.models import Sequential

from keras.layers import Dense, Dropout, Activation, Flatten

from keras.layers import Conv2D, MaxPooling2D

from sklearn.metrics import confusion_matrix, f1_score, precision_score, recall_score

from sklearn.model_selection import train_test_split

Using TensorFlow backend.


os.listdir('../input')
['reducing-image-sizes-to-32x32', 'iwildcam-2019-fgvc6']
# The data, split between train and test sets:

x_train = np.load('../input/reducing-image-sizes-to-32x32/X_train.npy')

x_test = np.load('../input/reducing-image-sizes-to-32x32/X_test.npy')

y_train = np.load('../input/reducing-image-sizes-to-32x32/y_train.npy')


print('x_train shape:', x_train.shape)

print(x_train.shape[0], 'train samples')

print(x_test.shape[0], 'test samples')
x_train shape: (196299, 32, 32, 3)

196299 train samples

153730 test samples
# Convert the images to float and scale it to a range of 0 to 1

x_train = x_train.astype('float32')

x_test = x_test.astype('float32')

x_train /= 255.

x_test /= 255.

In [5]:


linkcode

class Metrics(Callback):

def on_train_begin(self, logs={}):

self.val_f1s = []

self.val_recalls = []

self.val_precisions = []


def on_epoch_end(self, epoch, logs={}):

X_val, y_val = self.validation_data[:2]

y_pred = self.model.predict(X_val)
y_pred_cat = keras.utils.to_categorical(

y_pred.argmax(axis=1),

num_classes=num_classes

)
_val_f1 = f1_score(y_val, y_pred_cat, average='macro')

_val_recall = recall_score(y_val, y_pred_cat, average='macro')

_val_precision = precision_score(y_val, y_pred_cat, average='macro')


self.val_f1s.append(_val_f1)

self.val_recalls.append(_val_recall)

self.val_precisions.append(_val_precision)
print((f"val_f1:


Yüklə 80,96 Kb.

Dostları ilə paylaş:
  1   2




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2023
rəhbərliyinə müraciət

    Ana səhifə