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

相关推荐
SuAluvfy7 小时前
不存在“全能第一模型”,存在“任务空间中的局部最优模型”
人工智能·chatgpt·agent
workflower7 小时前
AI能源智慧生产与绿色开发核心场景
大数据·人工智能·设计模式·机器人·软件工程·能源
一块小土坷垃7 小时前
## CleanMyMac – macOS 强大的系统清理与优化工具
macos·开源软件
染指11107 小时前
4.AI大模型-幻觉、记忆、参数-大模型底层运行机制
人工智能
晓蓝WQuiet7 小时前
GAN生成对抗网络
人工智能·神经网络·生成对抗网络
闵孚龙7 小时前
Claude Code 权限系统全解析:AI Agent 安全治理、权限模式、规则匹配、沙箱防护与企业落地实战
人工智能·安全
测试员周周7 小时前
【Appium 系列】第10节-手势操作实战 — 滑动、拖拽、缩放与轻拂
linux·服务器·开发语言·人工智能·python·appium·pytest
耕烟煮云7 小时前
一篇文章讲清大语言模型发展史
人工智能·语言模型·自然语言处理
硅谷秋水7 小时前
ARIS:基于对抗性多智体协作的自主研究
人工智能·科技·机器学习·语言模型·软件工程
风酥糖7 小时前
Godot游戏练习01-第34节-开始引入AI开发
人工智能·游戏·godot