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

相关推荐
魔术师Grace6 小时前
从传统企业架构到 OPC 模式,AI 到底改变了什么?
人工智能·程序员
沪漂阿龙6 小时前
LangGraph 持久化完全指南:从零搭建永不丢失状态的 AI Agent 系统
人工智能·流程图
杨浦老苏6 小时前
大模型安全接入网关LinkAI
人工智能·docker·ai·群晖·隐私保护
档案宝档案管理6 小时前
权限分级管控,全程可追溯,筑牢会计档案安全防线
运维·网络·人工智能
Chat_zhanggong3456 小时前
主推RK3567J作用有哪些?
人工智能·嵌入式硬件
qq_411262426 小时前
四博 AI 机械臂台灯智能音箱方案:让台灯具备视觉、语音、动作和学习陪伴能力
人工智能·语音识别
AI+程序员在路上6 小时前
VS Code 完全使用指南:下载、安装、核心功能与 内置AI 编程助手实战
开发语言·人工智能·windows·开源
coderyi6 小时前
Agent协作简析
人工智能
霍小毛7 小时前
破局工业数据孤岛!数字孪生+AI智慧设备资产管理平台,重构智能运维新范式
人工智能·重构
AI人工智能+7 小时前
基于深度学习的银行回单识别技术,成为连接物理票据与数字财务系统的桥梁
深度学习·计算机视觉·ocr·银行回单识别