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服务老曹6 小时前
解耦安防黑盒:基于 Docker 的国标 GB28181 与 RTSP 统一接入 AI 视频管理平台架构设计(附源码交付与边缘计算实践)
人工智能·docker·音视频
chen_zn956 小时前
GR00T N1.7源码学习(三):动作头内部模块、DiT结构与多机器人条件编码解析
深度学习·具身智能·vla·gr00t
初中就开始混世的大魔王6 小时前
7 Fast DDS-持久化服务
c++·人工智能·中间件·自动驾驶·信息与通信
云边有个稻草人6 小时前
时序智能新范式:TimechoAI 大模型赋能工业时序数据全链路分析
人工智能·apache iotdb·时序大模型·timechoai·企业级时序数据解决方案·工业时序数据分析·时序 ai 赋能
Rudon滨海渔村6 小时前
macOS文件夹创建桌面快捷方式 - 发送到桌面快捷方式
macos
weixin_307779136 小时前
从工具到协作者:AI在后端研发中的流程重构与组织赋能
人工智能·后端·python·算法·自动化
云草桑6 小时前
.NET10+AI 架构师全套实战学习文档(含源码、案例、面试题、项目源码)
人工智能·学习·ai·.net
装不满的克莱因瓶6 小时前
循环神经网络及LSTM——从序列建模到长期依赖记忆机制
人工智能·pytorch·python·rnn·深度学习·神经网络·lstm
ai产品老杨6 小时前
突破安防碎片化僵局:基于 Docker 与边缘计算的 AI 视频管理平台异构架构设计(附 GB28181/RTSP 统一接入与源码交付)
人工智能·docker·边缘计算
沉下去,苦磨练!6 小时前
深度学习神经网络的搭建
人工智能·算法