Я получаю сообщение об ошибке при создании вспомогательной модели GAN для набора данных CSV в Python - PullRequest
0 голосов
/ 29 марта 2020

Я пытаюсь построить генератор и дискриминатор для набора данных CSV. Где я пытаюсь построить модель вспомогательной порождающей сети (GAN), но получаю некоторую ошибку при ее кодировании. Пожалуйста, помогите решить эти ошибки. Я открыт для предложений от всех. Заранее благодарим за проверку моей проблемы

Генератор

def create_generator():
    generator=Sequential()
    generator.add(Dense(units=64,input_dim=10))
    generator.add(LeakyReLU(0.2))

    generator.add(Dense(units=128))
    generator.add(LeakyReLU(0.2))

    generator.add(Dense(units=256))
    generator.add(LeakyReLU(0.2))


    generator.add(Dense(units=44, activation='tanh'))

    generator.compile(loss='binary_crossentropy', optimizer=Adam(lr=0.001, beta_1=0.5))
    return generator

Дискриминатор

def create_discriminator():

    discriminator = Sequential()
    discriminator.add(Dense(units = 256,input_dim = 44))
    discriminator.add(LeakyReLU(0.2))
    discriminator.add(Dropout(0.3))


    discriminator.add(Dense(units=128))
    discriminator.add(LeakyReLU(0.2))
    discriminator.add(Dropout(0.3))


    discriminator.add(Dense(units=64))
    discriminator.add(LeakyReLU(0.2))
    discriminator.add(Dropout(0.3))

#     inpu = Input(shape=(44,))

    value = discriminator(Input(shape=(44,)))



#     discriminator.add(Dense(units=1, activation='sigmoid'))
    discriminator_fake = Dense(units=1, activation='sigmoid')(value)
    discriminator_predict = Dense(units=2, activation='softmax')(value)

    model = Model(inputs = Input(shape=(44,)), outputs=[discriminator_fake,discriminator_predict])
#     discriminator.compile(loss='binary_crossentropy', optimizer='adam')

    model.compile(loss=['binary_crossentropy', 'sparse_categorical_crossentropy'], optimizer=Adam(lr=0.001, beta_1=0.5))
    return model

> ОШИБКА


 ValueError                                Traceback (most recent call last)
<ipython-input-76-9c8507bc9118> in <module>
----> 1 d = create_discriminator()
      2 d.summary()

<ipython-input-74-549be524fb33> in create_discriminator()
     26     discriminator_predict = Dense(units=2, activation='softmax')(value)
     27 
---> 28     model = Model(inputs = Input(shape=(44,)), outputs=[discriminator_fake,discriminator_predict])
     29 #     discriminator.compile(loss='binary_crossentropy', optimizer='adam')
     30 

e:\gan autofill\lib\site-packages\tensorflow_core\python\keras\engine\training.py in __init__(self, *args, **kwargs)
    145 
    146   def __init__(self, *args, **kwargs):
--> 147     super(Model, self).__init__(*args, **kwargs)
    148     _keras_api_gauge.get_cell('model').set(True)
    149     # initializing _distribution_strategy here since it is possible to call

e:\gan autofill\lib\site-packages\tensorflow_core\python\keras\engine\network.py in __init__(self, *args, **kwargs)
    162         'inputs' in kwargs and 'outputs' in kwargs):
    163       # Graph network
--> 164       self._init_graph_network(*args, **kwargs)
    165     else:
    166       # Subclassed network

e:\gan autofill\lib\site-packages\tensorflow_core\python\training\tracking\base.py in _method_wrapper(self, *args, **kwargs)
    455     self._self_setattr_tracking = False  # pylint: disable=protected-access
    456     try:
--> 457       result = method(self, *args, **kwargs)
    458     finally:
    459       self._self_setattr_tracking = previous_value  # pylint: disable=protected-access

e:\gan autofill\lib\site-packages\tensorflow_core\python\keras\engine\network.py in _init_graph_network(self, inputs, outputs, name, **kwargs)
    315     # Keep track of the network's nodes and layers.
    316     nodes, nodes_by_depth, layers, _ = _map_graph_network(
--> 317         self.inputs, self.outputs)
    318     self._network_nodes = nodes
    319     self._nodes_by_depth = nodes_by_depth

e:\gan autofill\lib\site-packages\tensorflow_core\python\keras\engine\network.py in _map_graph_network(inputs, outputs)
   1819                              'The following previous layers '
   1820                              'were accessed without issue: ' +
-> 1821                              str(layers_with_complete_input))
   1822         for x in nest.flatten(node.output_tensors):
   1823           computable_tensors.add(x)

ValueError: Graph disconnected: cannot obtain value for tensor Tensor("input_21:0", shape=(?, 44), dtype=float32) at layer "input_21". The following previous layers were accessed without issue: []

ERROR
...