当前位置:网站首页>【keras bug】Tensor is unhashable if Tensor equality is enabled. Instead, use tensor.experimental_ ref(
【keras bug】Tensor is unhashable if Tensor equality is enabled. Instead, use tensor.experimental_ ref(
2022-07-25 08:07:00 【ninetyfour】
/media/cfs/wangxin436/TCN/future-guide-model/dissales.py:161 call *
loss = tf.add(tf.cast(tf.multiply(tf.cast(weights,l1.dtype), loss_st),'float64'),
/usr/local/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/util/dispatch.py:180 wrapper
return target(*args, **kwargs)
/usr/local/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/ops/math_ops.py:686 cast
base_type = dtypes.as_dtype(dtype).base_dtype
/usr/local/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/framework/dtypes.py:716 as_dtype
return _ANY_TO_TF[type_value]
/usr/local/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py:713 __hash__
raise TypeError("Tensor is unhashable if Tensor equality is enabled. "
TypeError: Tensor is unhashable if Tensor equality is enabled. Instead, use tensor.experimental_ref() as the key.When encountering such problems , The first point is the version incompatibility , So what are the solutions to incompatibility ,
First of all , Upgraded version , Be compatible , Usually 2.0 The above will not encounter such problems
keras.__version__
tf.__version__
# Observe code version Upgraded version
pip install keras
pip install tensorflowIf it can't be solved
In fact, you can check what is wrong in your code , The problem with my code is tf.cast() Use , stay TF2.0+ In the process of execution , In fact, there is no need for personal designation tensor The type of , The code can automatically match the corresponding type , What we need to do is delete the data type specified by individuals
such as
tf.multiply(tf.cast(weights,l1.dtype), l1) + tf.multiply(tf.cast((1-weights,l2.dtype), l2))
# It is amended as follows
tf.multiply(weights, l1) + tf.multiply(1-weights, l2)About the version , You can also have a look at
stackoverflow How to explain , In short, modifying personal code is the right way , Others are made compatible , Of course, you can't get away with other people's code , If you don't want to modify it, you can only upgrade the version
边栏推荐
- 第3章业务功能开发(查询线索)
- RK3399开发板I2C4挂载EEPROM实例
- 设计一个有getMin功能的栈
- Raspberry pie 4B ffmpeg RTMP streaming
- How to obtain the intersection / subtraction / Union of two sets by MySQL
- Competition path design of beacon group
- Implement hot post | community project with timed tasks and cache
- Weblux default IO threads
- My creation anniversary
- 滴滴 - dispatching
猜你喜欢

enq: HW – contention等待引起的故障分析

475-82(230、43、78、79、213、198、1143)

A powerful port scanning tool (nmap)

Brush the title "sword finger offer" day02

UNIPRO multi terminal deployment to meet customers' diversified needs

Raspberrypico analytic PWM

Oracle trigger creation

Supplementary notes on Relevant Issues of complete model group

How to create a simple electron desktop program

"Unable to recognize" yarn "item as cmdlet, function, script file
随机推荐
【着色器实现Shadow投影效果_Shader效果第八篇】
Big guy Qiu zhaomianjing
Raspberry pie uses the command line to configure WiFi connections
[recommended reading] a collection of super useful vulnerability scanning tools!
Calculation formula of cross entropy
Vs2019 C MFC installation
Redis分片集群
app耗电量测试
Use of toolbar
Network file storage system (III) practice of fastdfs distributed file system
How to create a simple electron desktop program
Rk3399 development board i2c4 attaching EEPROM instance
机器学习理论及案例分析(part2)--回归
yolov7 网络架构深度解析
Eval and assert one sentence Trojan horse analysis
Teach you to understand the computer optometry sheet
Test the mock data method of knowing and knowing
How to do a good job in safety development?
Codeforces Round #809 Editorial(A,B,C)
Supplementary notes on Relevant Issues of complete model group