Deep Learning(3)

Linear Units in Keras

The easiest way to create a model in Keras is through 'keras.Sequential', which creates a stack of layers from a neural network. Of course, we can also use a dense layer to create the model.

We can define a linear model that takes three input features ('sugars', 'fiber', and 'protein') and then generate a simgle output ('calories') like this:

python 复制代码
from tensorflow import keras
from tensorflow.keras import layers

# Create a network with 1 linear unit
model = keras.Sequential([
    layers.Dense(units=1, input_shape=[3])
])

With the first parameter, 'units' , we define how many outputs we want. In this case, we're just predicting 'calories', so we'll use 'units = 1'.

With the second parameter, 'input_shape', we tell Keras the dimension of the inputs. Setting 'input_shape=[3]' ensures that the model will accept three features as input ('sugars', 'fiber', and 'protein').

This model is now ready to be fit to training data

相关推荐
minstbe20 分钟前
IC设计私有化AI助手实战:基于Docker+OpenCode+Ollama的数字前端综合增强方案(进阶版)
人工智能·python·语言模型·llama
GinoInterpreter1 小时前
什么是翻译的去中心化?
人工智能·自然语言处理·去中心化·区块链·机器翻译·机器翻译模型·机器翻译引擎
码农小白AI2 小时前
IACheck AI报告文档审核:高端制造合规新助力,保障标准引用报告质量
大数据·人工智能·制造
_YiFei2 小时前
哪个降论文AI率工具最好用?
人工智能·深度学习·神经网络
放下华子我只抽RuiKe52 小时前
机器学习全景指南-直觉篇——基于距离的 K-近邻 (KNN) 算法
人工智能·gpt·算法·机器学习·语言模型·chatgpt·ai编程
kisshuan123962 小时前
[特殊字符]【深度学习】DA3METRIC-LARGE单目深度估计算法详解
人工智能·深度学习·算法
sali-tec3 小时前
C# 基于OpenCv的视觉工作流-章33-Blod分析
图像处理·人工智能·opencv·算法·计算机视觉
老星*3 小时前
Trae-cn一句话安装OpenClaw:AI智能体框架快速部署指南
人工智能·编辑器
昨夜见军贴06163 小时前
IACheck结合AI报告审核:轨道扣件横向阻力检测报告确保无误差
人工智能
Qt学视觉3 小时前
AI2-Paddle环境搭建
c++·人工智能·python·opencv·paddle