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

相关推荐
da_vinci_x20 分钟前
Painter AI 材质 x 智能遮罩:告别“风格化”手K地狱
人工智能·aigc·材质·设计师·技术美术·工作流·游戏美术
盈飞无限22 分钟前
质量智能革命:SPC软件助力中国制造驶入高质量发展快车道
大数据·人工智能·制造
onebound_noah32 分钟前
从“识图”到“购得”:图片搜索商品如何重构消费与供应链逻辑?
人工智能·重构
AI_56781 小时前
AI开发革命:PyCharm科学计算模式重塑TensorFlow调试体验
人工智能·ai·neo4j
算家计算1 小时前
AGI为何被“判死刑”?李飞飞最新万字长文,指出一个致命缺失
人工智能·资讯
野豹商业评论1 小时前
三次更名的背后:百度AI的定位困惑
人工智能·百度
BianHuanShiZhe1 小时前
ios 26的tabbar 背景透明
macos·objective-c·cocoa
老蒋新思维1 小时前
2025 创客匠人全球创始人 IP + AI 万人高峰论坛:破局创业困境,拥抱无限未来
大数据·网络·人工智能·网络协议·tcp/ip·创客匠人·知识变现
永霖光电_UVLED1 小时前
EPC的GaN电源ic瞄准了机器人的敏捷性
人工智能·制造
Chef_Chen2 小时前
数据科学每日总结--Day13--数据挖掘
人工智能·数据挖掘