[Python] How to create input layer in keras for class label also?

Discussão em 'Python' iniciado por Stack, Agosto 11, 2025.

  1. Stack

    Stack Membro Participativo

    I wanted the class label information for my model to build a custom loss function similar to arcface how do I get input values of shape(1) in keras

    X_input = Input(InputShape)
    label = Input(shape=(1,))
    #there are some more layers in between
    model = Model(inputs = [X_input,label], outputs = X, name='MNIST')
    newModelArc(InputShape=(108,108,3),number_class=5749)


    I get this error

    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='MNIST')
    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]

    Continue reading...

Compartilhe esta Página