MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI NURAFSHON FILIALI
Kompyuter Injiniring Fakulteti
3-kurs 210-21 gurux talabasi
AMALIY ISH
Fan:Mashinali Oqitish
Tayyorladi: Quvonch Toshtemirov
TOSHKENT-2023
Dataset yaratish va tasvirlash:
import matplotlib.pyplot as plt
import random
# Ixtiyoriy dataset yaratish
random.seed(42)
data_points = 50
feature1 = [random.uniform(0, 10) for _ in range(data_points)]
feature2 = [random.uniform(0, 10) for _ in range(data_points)]
# Datasetni tasvirlash
plt.scatter(feature1, feature2, color='blue', label='Dataset')
# Grafikni tuzish
plt.title('Ixtiyoriy Dataset Xususiyatlari')
plt.xlabel('Xususiyat 1')
plt.ylabel('Xususiyat 2')
plt.legend()
plt.grid(True)
# Grafikni ko'rsatish
plt.show()
Tensorflow kutubxonasidan foydalanib neyron arxitekturasini qurish
import tensorflow as tf
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# Ixtiyoriy dataset yaratish
np.random.seed(42)
data_points = 50
feature1 = np.random.uniform(0, 10, data_points)
feature2 = np.random.uniform(0, 10, data_points)
# Datasetni tasvirlash
plt.scatter(feature1, feature2, color='blue', label='Dataset')
plt.title('Ixtiyoriy Dataset Xususiyatlari')
plt.xlabel('Xususiyat 1')
plt.ylabel('Xususiyat 2')
plt.legend()
plt.grid(True)
plt.show()
# Neyron tarmoq arxitekturasi
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, activation='relu', input_shape=(2,)),
tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(1)
])
# O'qitish parametrlarini tanlash
model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.001),
loss='mse',
metrics=['mae'])
# Tarmoqni o'qitish
train_data = np.column_stack((feature1, feature2)) # Datasetni tayyorlash
train_labels = np.random.rand(data_points, 1) # Natijalarni boshlash uchun tasodifiy generatsiya
history = model.fit(train_data, train_labels, epochs=100, validation_split=0.2, verbose=0)
# Natijalarni visual ko'rsatish
train_loss = history.history['loss']
val_loss = history.history['val_loss']
epochs = range(1, len(train_loss) + 1)
plt.plot(epochs, train_loss, 'bo', label='Train loss')
plt.plot(epochs, val_loss, 'b', label='Validation loss')
plt.title('O\'rtacha Sinov Tarmoqning O\'qitish Jarayoni')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.legend()
plt.show()
# Natijalarni jadvalga joylash
results = pd.DataFrame({'Epoch': epochs, 'Train Loss': train_loss, 'Validation Loss': val_loss})
print(results)
|