• 5-AMALIY TOPSHIRIQ
  • Ishni bajarish uchun kerakli kutubxonalarni chaqirib olamiz
  • Yaratilgan dataset ning ixtiyoriy ikkita xususiyatini (Bo’yi vaVazni ) olgan holda matplotlib kutubxonasidan foydalanib grafik tasviri.
  • Yaratilgan datasetni modelni o’qitish uchun 90 % va testlash uchun 10% nisbatda bo’laklarga ajratamiz
  • Keras kutubxonasidan foydalanib masalaga mos neyron tarmoq arxitekturasini quramiz
  • Neyon tarmoqni o’qitish paramertlarini(o’qish qadami-lr, o’qitishlar soni-epoch) tanlash
  • Neyron tarmoqning o’qitish natijalarini garfik tarviri
  • Model aniqligini(o’rgatuvchi tanalama uchun)
  • Modelni test to’plam bilan testlash. Modelini test to’plamdagi aniqligi
  • Ishni bajarish uchun kerakli kutubxonalarni chaqirib olamiz




    Download 202,33 Kb.
    Sana14.02.2024
    Hajmi202,33 Kb.
    #156192
    Bog'liq
    1702716692 (2)


    O’ZBEKISTON RESPUBLIKASI RAQAMLI
    TEXNOLOGIYALAR VAZIRLIGI

    MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

    5-AMALIY ISH
    MASHINALI O’QITISHGA KIRISH
    KIBERXAVFSIZLIK FAKULTETI
    712-21 guruh talabasi
    Bajardi: Aliqulov Azizjon
    Tekshirdi: Ochilov Mannon

    Toshkent 2023




    5-AMALIY TOPSHIRIQ
    Mavzu: Sun’iy neyron tarmoqlari. Sodda neyron tarmoqlarini qurish. Neyron tarmoqlarining to‘gri va teskari tarqalish algoritmlari


    3

    Uy hayvonlarini sinflashtirish

    60

    3

    4

    1. Ishni bajarish uchun kerakli kutubxonalarni chaqirib olamiz


    import numpy as np
    import pandas as pd
    import matplotlib.pyplot as plt
    df = pd.read_csv('pet2.csv')
    df.head()
    Datasetimizni dastlabki 5 elementini chiqaramiz

    x = df.iloc[:, [0,1]].values
    y = df.iloc[:, 1].values
    c=df.iloc[:,-1].values
    Yaratilgan dataset ning ixtiyoriy ikkita xususiyatini (Bo’yi vaVazni ) olgan holda matplotlib kutubxonasidan foydalanib grafik tasviri.
    plt.xlabel(‘Yoshi’)
    plt.ylabel('Vazni')
    plt.scatter(x[:,0], x[:,1], marker='^',color='green')
    plt.legend()
    plt.show()

    from keras.utils import to_categorical
    y=to_categorical(Y).astype(int)
    Yaratilgan datasetni modelni o’qitish uchun 90 % va testlash uchun 10% nisbatda bo’laklarga ajratamiz
    from sklearn.model_selection import train_test_split

    train_x, test_x, train_y, test_y = train_test_split(X, y, test_size=0.1)


    train_x.shape
    test_y.shape
    Keras kutubxonasidan foydalanib masalaga mos neyron tarmoq arxitekturasini quramiz
    from keras.models import Sequential

    from keras.layers import Dense


    from keras.optimizers import Adam,SGD


    model = Sequential()

    model.add(Dense(8, input_dim=4, activation='relu', name='fc1'))


    model.add(Dense(10, activation='relu', name='fc2'))
    model.add(Dense(4, activation='softmax', name='output'))
    print('Neyron tarmoq aritekturasi:')
    print(model.summary())

    Neyon tarmoqni o’qitish paramertlarini(o’qish qadami-lr, o’qitishlar soni-epoch) tanlash
    optimizer = Adam(learning_rate=0.001)
    model.compile(optimizer, loss='categorical_crossentropy', metrics=['accuracy'])
    history = model.fit(train_x, train_y, verbose=1, batch_size=2, epochs=100)

    Neyron tarmoqning o’qitish natijalarini garfik tarviri
    plt.figure(figsize=(12,4))

    plt.subplot(121)


    plt.plot(history.history['accuracy'])
    plt.title('Model accuracy')
    plt.ylabel('Accuracy')
    plt.xlabel('Epoch')
    plt.grid()

    plt.subplot(122)


    plt.plot(history.history['loss'])
    plt.title('Model loss')
    plt.ylabel('Loss')
    plt.xlabel('Epoch')
    plt.grid()

    plt.show()



    Model aniqligini(o’rgatuvchi tanalama uchun)
    results = model.evaluate(train_x, train_y)

    print("O'rgatuvchi tanlama uchun yakuniy loss xatoligi: : {:4f}".format(results[0]))


    print("O'rgatuvchi tanlama uchun yakuniy aniqliq(accuracy): {:4f}".format(results[1]))

    Modelni test to’plam bilan testlash. Modelini test to’plamdagi aniqligi
    results = model.evaluate(test_x, test_y)

    print("Test to'lam uchun yakuniy loss xatoligi: : {:4f}".format(results[0]))


    print("Test to'plam uchun yakuniy aniqliq(accuracy): {:4f}".format(results[1]))

    Download 202,33 Kb.




    Download 202,33 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Ishni bajarish uchun kerakli kutubxonalarni chaqirib olamiz

    Download 202,33 Kb.