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

相关推荐
动物园猫13 小时前
桑叶病害目标检测数据集:16,000张图像 | 目标检测
人工智能·目标检测·计算机视觉
金融小师妹13 小时前
多因子智能建模:国内黄金需求结构调整与供给变化的AI分析框架
大数据·人工智能
科技新资讯13 小时前
AI写小说软件FeelFish 4.0实测,多部门协作重塑创作全流程
人工智能
IT_陈寒13 小时前
Vite打包时静态资源404?加个斜杠就能解决
前端·人工智能·后端
码农小旋风13 小时前
26个PPT生成Skill,我做了一次系统梳理
人工智能·ppt
ccLianLian13 小时前
机器学习和深度学习
人工智能·深度学习·机器学习
向阳是我13 小时前
两台 Mac 远程共享屏幕最佳方案:Tailscale + macOS 原生屏幕共享
macos
许泽宇的技术分享13 小时前
我拆了一个 Agent 仓库,发现真正难的从来不是让 AI 会写代码
人工智能
webor200613 小时前
<六>ChatGPT到底叫什么?——语言模型
人工智能·ai·语言模型·chatgpt·claude
dunge202613 小时前
ChatGPT Plus / Pro + Codex 技术深度解析:从 API 集成到性能优化与实战案例
人工智能·chatgpt