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

相关推荐
TMT星球几秒前
度小满与香港科技大学联合发布轩辕4.5金融大模型
人工智能·金融
地平线开发者1 分钟前
CLIP 的训练机制:从对比学习到图文对齐
深度学习·算法·自动驾驶
GJGCY2 分钟前
金融AI Agent安全如何评估?数据出站、身份映射、参数绑定与审计追踪机制
人工智能·经验分享·安全·ai·金融·自动化·智能体
甲维斯5 分钟前
Codex,Zcode,KimiCode电脑操作能力对比!
人工智能·游戏开发
ckjr0079 分钟前
手机里的AI功能越来越多,如何让它真正提高日常使用效率?
人工智能·智能手机
美狐美颜SDK开放平台10 分钟前
开发直播APP、电商短视频与视频社交平台时,能否共用一套美颜SDK?
android·图像处理·人工智能·音视频·直播美颜sdk
youzuos11 分钟前
大模型面试别背术语:用一次故障讲清工程能力:工程拆解与验证
人工智能
财迅通Ai17 分钟前
MLCC业务爆发式增长,带动昀冢科技三季度扭亏为盈
大数据·人工智能·科技·昀冢科技
AI日报派送佬18 分钟前
2026年11月02日 AI 行业日报|商汤开源 Loop-9B、Pika 发布 H3 Flex 音视频模型、Meta× 傅利叶推出人形机器人 Max
人工智能·微软·开源·音视频·openai·1024程序员节·ai日报
义嘉泰19 分钟前
心率能测出来不难,难的是低功耗、稳定、还能量产
人工智能·科技