google-colaboratory - 在 Google Collaboratory 中,告诉 AI/ML 在屏幕上显示/打印它预测的模型的代码是什么?
问题描述
请参阅下面的代码以了解基本的 ML 测试。我运行了这个,但想看看 AI 使用给定的 xs 和 ys 数组集预测的数学公式,以及训练的 x 值。
import tensorflow as tf
import numpy as np
from tensorflow import keras
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss = 'mean_squared_error')
xs = np.array([-3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0], dtype=float)
ys = np.array([-3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0], dtype=float)
model.fit(xs,ys,epochs=10)
print(model.predict([-2.5]))
解决方案
推荐阅读
- php - 如何根据 laravel 上博客文章的 user_id 显示用户的照片?
- python-3.x - 在列表中追加时出现运行时错误
- python - 恢复 TensorFlow 模型的方式差异
- c# - 如何返回 JSON 响应对象
- c# - 基于下拉框中的值的复选框验证
- apache-pig - 如何从列中的字符串列表中提取特定单词
- sql - SQL Server:Group By 导致“列无效”错误,如何解决?
- r - 闪亮 - 使用 appendTab 时折叠侧边栏
- python - 如何使用 parallel_coordinates 操作包含多行信号并绘制信号与时间的数据帧?
- wordpress - 如何将规范 URL 添加到 example.com/blog?