Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to create model in tensorflow

# Simple Model in Tensorflow

import tensorflow as tf
from tensorflow import keras
import numpy as np

#creating model
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])

#input to model
xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)
ys = np.array([-2.0, 1.0, 4.0, 7.0, 10.0, 13.0], dtype=float)

model.compile(optimizer='sgd', loss='mean_squared_error')

#Now train the model
model.fit(xs, ys, epochs=500)

#Using Model
print(model.predict([10.0]))
Comment

PREVIOUS NEXT
Code Example
Python :: python regular expression remove numbers 
Python :: Python Tkinter ListBox Widget 
Python :: python-telegram-bot 
Python :: how to select a file in python 
Python :: drop rows from dataframe based on column value 
Python :: string formatting in python 
Python :: how to print answer 2 decimal places in python 3 
Python :: change xlabel rotate in seaborn 
Python :: text to audio in python 
Python :: venv 
Python :: reload flask on change 
Python :: default flask app 
Python :: path to create a text file in python 
Python :: python how to replace a certain string in text 
Python :: how to sort list of dictionaries in python 
Python :: pywhatkit send message 
Python :: django dockerfile multistage 
Python :: create a blank image numpy 
Python :: list all files starting with python 
Python :: how to save an image with the same name after editing in python pillow module 
Python :: numpy vector multiplication 
Python :: count repeated characters in a string python 
Python :: Origin in CORS_ORIGIN_WHITELIST is missing scheme or netloc 
Python :: fromkeys in python 
Python :: python asctime 
Python :: leap year 
Python :: python check if key exists 
Python :: newsapi in python 
Python :: python slice a dict 
Python :: norm in python 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =