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

相关推荐
星爷AG I15 小时前
15-5 身体感觉:疼觉和温觉(AGI基础理论)
人工智能·agi
云和数据.ChenGuang15 小时前
鸿蒙餐饮系统:全场景智慧餐饮新范式
人工智能·机器学习·华为·数据挖掘·harmonyos·鸿蒙·鸿蒙系统
苍何15 小时前
个人微信正式支持接入龙虾,附一键接入教程!
人工智能
Swift社区16 小时前
AI 驱动 UI:鸿蒙 ArkUI 的新可能
人工智能·ui·harmonyos
Lab_AI16 小时前
科学智能AI4S应用:人工智能加速加速抗生素发现(AIDD助力药物研发)
人工智能·神经网络·机器学习·ai4s·药物研发·aidd
用户27042728381216 小时前
OpenClaw,Token费用控制
人工智能
唯创知音16 小时前
Stickerbox儿童AI贴纸打印机国产替代方案
人工智能
AI袋鼠帝16 小时前
劲爆!个人微信官方接入龙虾了【喂饭级教程】
人工智能·微信
柯儿的天空16 小时前
【OpenClaw 全面解析:从零到精通】第 016 篇:OpenClaw 实战案例——代码开发助手,从代码生成到部署自动化的全流程
运维·人工智能·ai作画·自动化·aigc·ai写作
我科绝伦(Huanhuan Zhou)16 小时前
从自动化到自主化—AI Agent引领的运维范式变革
运维·人工智能·自动化