当前位置:网站首页>TensorFlow求梯度时提示TypeError: unsupported operand type(s) for *: ‘float‘ and ‘NoneType‘
TensorFlow求梯度时提示TypeError: unsupported operand type(s) for *: ‘float‘ and ‘NoneType‘
2022-06-12 17:14:00 【老油条666】
报错代码如下:
,变量声明如下:
![]()
这是因为使用的张量类型不对,在TensorFlow中的tensor一旦涉及到求梯度和梯度更新问题时,需要使用特殊的tensor:Variable,即将原来的tensor直接强转为Variable即可。
![]()
另外,如果是手动实现梯度下降算法,tensorflow中不能使用第一张截图的那种直接相减方式,而是应该使用TensorFlow中的assign_sub()函数,原因见下图中的注释:

参考链接:龙良曲老师的《深度学习与TensorFlow2入门实战》课时39前向传播-4,B站链接:https://www.bilibili.com/video/BV165411j7ro?from=search&seid=4255840397349822501
这个问题可能对于早已经熟悉TensorFlow的大佬们来说不是什么问题,但是对于我像我这种新手来说第一次遇到的时候是一头雾水,所以写下这篇博文记录一下
边栏推荐
- Yyds dry goods inventory leetcode question set 911 - 920
- php 实现无限极分类树(递归及其优化)
- R language arma-garch-copula model and financial time series case
- Selenium element positioning
- The R language uses the tabpct function of the epidisplay package to generate a two-dimensional contingency table, and uses the mosaic diagram to visualize the contingency table (two-dimensional conti
- Google browser debugging skills
- Feedback compilation
- Cloud development kunkun chicken music box wechat applet source code
- 5-5 configuring MySQL replication log point based replication
- bug记录:更新数据库时报错:Data truncation: Incorrect datetime value:
猜你喜欢

goland变成中文版了怎么修改回英文版

龙芯处理器内核中断讲解

Atlas conflict Remote Code Execution Vulnerability (cve-2022-26134) vulnerability recurrence

内核中断整体流程图

1.5 什么是架构师(连载)

Record the use of yolov5 to detect rotating targets

How to use the official documents of pytorch and torchvision

Compilation optimization of performance optimization

Selenium element positioning

Some minor problems and solutions encountered when using ubantu
随机推荐
How to use the official documents of pytorch and torchvision
力扣今日题926. 将字符串翻转到单调递增
R语言使用pdf函数将可视化图像结果保存到pdf文件中、使用pdf函数打开图像设备、使用dev.off函数关闭图像设备、自定义width参数和height参数指定图像的宽度和高度
Gerrit triggers Jenkins sonarqube scan
大端模式和小端模式的區別
ftrace
R language uses the sum function of epidisplay package to calculate the descriptive statistical summary information of the specified variables in dataframe under different grouped variables and visual
The safety of link 01 was questioned, and "ultra high strength" became "high strength"_ Publicity_ Steel_ problem
D. master router setting and 401 networking
全局锁、表锁、行锁
Crazy temporary products: super low price, big scuffle and new hope
Detailed explanation of shardingjdbc database and table
Some minor problems and solutions encountered when using ubantu
Hangzhou AI developer meetup registration opens!
Gerrit触发Jenkins SonarQube扫描
(八)goto关键字
Difference between big end mode and small end mode
写技术博客的意义
MIPS 通用寄存器 + 指令
JDBC几个坑