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

相关推荐
lauo2 分钟前
互动影游的Token经济革命:ibbot手机如何成为AI互动娱乐的生产节点
人工智能·智能手机·娱乐
CIO_Alliance2 分钟前
鼎捷和钉钉系统集成破局:iPaaS成制造业破解“系统割裂”关键
人工智能·钉钉·ipaas·系统集成·制造业·企业数智化转型·零售电商
FL16238631294 分钟前
Synapse腹部CT多器官分割数据集png图片+掩码图片+颜色映射表
人工智能·计算机视觉
Raink老师5 分钟前
【AI面试临阵磨枪-97】多模态 RAG:图文混合切块、跨模态检索、多模态生成?
人工智能
winlife_5 分钟前
全程用 AI 做一款商业级手游 · EP0 立项:能做到吗、怎么做、边界在哪
人工智能·unity·ai编程·游戏开发·商业化·mcp·funplay
keykey6.5 分钟前
反向传播与梯度下降:神经网络如何学习
开发语言·人工智能·深度学习·机器学习
晚笙coding8 分钟前
从零讲透 LangChain 提示词模板:不只是 Prompt,而是“可复用的 AI 指令工厂”
人工智能·langchain·prompt
码农杂谈00078 分钟前
AI + 制造,正在从“能用“迈向“好用“ !网易创新企业大会回顾
人工智能
烟雨江南7859 分钟前
地铁越江隧道盾构机控制室大功率液压马达强低频共振降噪与离线智能参数抄报 ASR 方案
人工智能·语音识别·ai质检
RD_daoyi9 分钟前
GEO优化能为企业带来哪些价值?
大数据·人工智能·学习·搜索引擎·chatgpt