python - 如何在 keras 中为类标签创建输入层?
问题描述
我想要我的模型的类标签信息来构建一个类似于 arcface 的自定义损失函数我如何在 keras 中获取 shape(1) 的输入值
X_input = Input(InputShape)
label = Input(shape=(1,))
#there are some more layers in between
model = Model(inputs = [X_input,label], outputs = X, name='MNSIT')
newModelArc(InputShape=(108,108,3),number_class=5749)
Traceback (most recent call last):
File "D:\FaceRecognition\ClassifyModel.py", line 209, in <module>
FRmodel = newModelArc(InputShape=(108,108,3),number_class=5749)
File "D:\FaceRecognition\ClassifyModel.py", line 203, in newModelArc
model = Model(inputs = [X_input,label], outputs = X, name='MNSIT')
File "C:\Program Files\Python37\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "C:\Program Files\Python37\lib\site-packages\keras\engine\network.py", line 94, in __init__
self._init_graph_network(*args, **kwargs)
File "C:\Program Files\Python37\lib\site-packages\keras\engine\network.py", line 241, in _init_graph_network
self.inputs, self.outputs)
File "C:\Program Files\Python37\lib\site-packages\keras\engine\network.py", line 1434, in _map_graph_network
tensor_index=tensor_index)
File "C:\Program Files\Python37\lib\site-packages\keras\engine\network.py", line 1421, in build_map
node_index, tensor_index)
File "C:\Program Files\Python37\lib\site-packages\keras\engine\network.py", line 1393, in build_map
node = layer._inbound_nodes[node_index]
AttributeError: 'NoneType' object has no attribute '_inbound_nodes'
[Finished in 6.5s]
我得到这个错误
解决方案
推荐阅读
- python - Python:如何使用 MIDO 库标记 .midi 文件
- javascript - 通过注入的JS脚本更改输入框的值时如何触发onchange事件
- api - 哪个是在 kubernetes 集群上运行 API 测试的正确 IP
- javascript - React Swiper.js 滑块仅适用于页面调整大小
- html - 如何使用 Kuchiki 获取 HTML 文档的所有文本(script/style/noscript 标签除外)?
- spring-boot - 无法在变体 productionRuntimeClasspath 和 runtimeElements 之间进行选择
- android - 如何为 .glb 文件 Sceneform ARCore 的可渲染实例提供材质
- python - 我如何确保 pytest 夹具功能只执行一次,而不管同一模块中有多少次调用
- c++ - 为什么 [[carries_dependency]] 不是 C++ 中的默认值?
- java - Groovy DSL Spring 云合约为具有 Unicode 字符的查询参数抛出 java.lang.IllegalStateException