Exemplo n.º 1
0
def get_captioning_encoder(config):
    """Get captinoning model's encoder based on config."""
    if config['name'] == 'state':
        return MLPEncoder(embedding_dim=config['embedding_dim'],
                          name='captioning_encoder',
                          subtract_neighboring_observation=True)
    elif config['name'] == 'image':
        return CNNEncoder(embedding_dim=config['embedding_dim'],
                          name='captioning_encoder')
    else:
        raise ValueError('Unrecognized model type: {}'.format(config['name']))
Exemplo n.º 2
0
def get_answering_encoder(config):
    """Get answering model's encoder based on config."""
    if config['name'] == 'state':
        return MLPEncoder(embedding_dim=config['embedding_dim'],
                          name='answering_encoder')
    elif config['name'] == 'state-film':
        return tf.keras.layers.Lambda(lambda x: x)
    elif config['name'] == 'image':
        return CNNEncoderSingleFrame(embedding_dim=config['embedding_dim'],
                                     name='answering_encoder')
    else:
        raise ValueError('Unrecognized model type: {}'.format(config['name']))