# -*- coding: utf-8 -*-
import tensorflow as tf
import numpy as np
print("TensorFlow verzió:", tf.__version__)
# Tanító adatok
x_train = np.array([1, 2, 3, 4, 5, 6], dtype=float)
y_train = np.array([2, 4, 6, 8, 10, 12], dtype=float)
# Modell létrehozása
model = tf.keras.Sequential([
tf.keras.layers.Dense(units=1, input_shape=[1])
])
# Fordítás
model.compile(
optimizer='sgd',
loss='mean_squared_error'
)
# Tanítás
print("Tanítás folyamatban...")
model.fit(x_train, y_train, epochs=500, verbose=0)
# Teszt
ertek = float(input("Adj meg egy számot: "))
eredmeny = model.predict(np.array([ertek]), verbose=0)
print(f"A hálózat becslése: {eredmeny[0][0]:.2f}")
print(f"A várható érték: {ertek * 2:.2f}")
------------
https://colab.research.google.com/drive/1OnLX14o40lEh-ahU_NlGxhisUzyP8Tic
Nincsenek megjegyzések:
Megjegyzés küldése