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

相关推荐
阿里云大数据AI技术8 分钟前
Hologres 长记忆服务 LoCoMo 评测登顶世界第一,刷新多项 SOTA
人工智能
achong11 分钟前
PenguinHarness实测:LlamaFactory作者新作,0.2元造自进化Agent
人工智能·深度学习
AlloyTeamZy13 分钟前
我发现,一个人做小游戏最难的,根本不是写代码
前端·人工智能·程序员
Hotchip_MEMS16 分钟前
当雾化器遇上MEMS:一场从交互到制造的全链路效率提升
人工智能·笔记·物联网·电脑·制造
是上好佳佳佳呀25 分钟前
【深度学习|Day02】PyTorch 深度学习笔记(下):张量运算与自动微分
pytorch·笔记·深度学习
水如烟1 小时前
孤能子视角:LLM是续指代投器——从“续指论”与“代投机制”看大语言模型的本质定位
人工智能
BerryS3N1 小时前
2026年AI前沿技术全景深度解析:大模型推理范式变革、Agentic AI工程架构与底层基础设施演进
人工智能·架构
天天爱吃肉82181 小时前
【重磅发布:拿下新超仁达代理权 】
大数据·人工智能·python·功能测试·汽车
HIT_Weston1 小时前
167、【Agent】【OpenCode】TuiThreadCmd(EvenSource)
人工智能·agent·opencode
TunerT_TQ1 小时前
Valhalla 静态工程审阅 #022|百度PaddlePaddle 源码证据驱动评测【大厂开源基础设施特辑】
人工智能·百度·开源·paddlepaddle·#深度学习·#飞桨