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

相关推荐
围炉聊科技1 分钟前
这里deepseek-v4-flash hy3 今年免费用——智能体基建系列
人工智能
XuCoder4 分钟前
大模型推理的两阶段:一次 Prefill,加上多次 Decode
人工智能
xsd2024111815 分钟前
Ferret-UI Lite深度解析:Apple 3B端侧GUI Agent如何用缩放+强化学习超越7B模型
人工智能
qq_1612413519 分钟前
超精密光学用CVD单晶金刚石:北睿科技的工艺路径探讨
人工智能·科技·半导体
hfywmsj27 分钟前
广州餐饮铺位招租数据分析:选址权重模型与租金评估实操
人工智能·python·数据分析·广州餐饮铺位招租
星期一研究室28 分钟前
拥有创造力的人,就像一只边牧
人工智能·开源·产品
Quor28 分钟前
小程序工作室:AI 生成即运行的可视化工作台
人工智能·小程序
甜辣uu28 分钟前
智能体Agent性能优化从原理到实战
人工智能·性能优化·大模型·llm·agent·rag·智能体
4SAPI31 分钟前
GPT-6 Astra 发布:AGI 时代是否到来,或许不是当前最重要的问题
大数据·人工智能·gpt·agi
星期一研究室41 分钟前
别人家养边牧,我家养了个吞电的Codex
人工智能·产品·资讯