• keras2


    num_tags = 12  # Number of unique issue tags
    num_words = 10000  # Size of vocabulary obtained when preprocessing text data
    num_departments = 4  # Number of departments for predictions
    
    title_input = keras.Input(
        shape=(None,), name="title"
    )  # Variable-length sequence of ints
    body_input = keras.Input(shape=(None,), name="body")  # Variable-length sequence of ints
    tags_input = keras.Input(
        shape=(num_tags,), name="tags"
    )  # Binary vectors of size `num_tags`
    
    # Embed each word in the title into a 64-dimensional vector
    title_features = layers.Embedding(num_words, 64)(title_input)
    # Embed each word in the text into a 64-dimensional vector
    body_features = layers.Embedding(num_words, 64)(body_input)
    
    # Reduce sequence of embedded words in the title into a single 128-dimensional vector
    title_features = layers.LSTM(128)(title_features)
    # Reduce sequence of embedded words in the body into a single 32-dimensional vector
    body_features = layers.LSTM(32)(body_features)
    
    # Merge all available features into a single large vector via concatenation
    x = layers.concatenate([title_features, body_features, tags_input])
    
    # Stick a logistic regression for priority prediction on top of the features
    priority_pred = layers.Dense(1, name="priority")(x)
    # Stick a department classifier on top of the features
    department_pred = layers.Dense(num_departments, name="department")(x)
    
    # Instantiate an end-to-end model predicting both priority and department
    model = keras.Model(
        inputs=[title_input, body_input, tags_input],
        outputs=[priority_pred, department_pred],
    )
    现在绘制模型: 
    keras.utils.plot_model(model, "multi_input_and_output_model.png", show_shapes=True)
  • 相关阅读:
    git使用
    MySQL Slow Log慢日志分析【转】
    PHP中的魔术方法【转载】
    在线修改MySQL大表的表结构
    tastypie Django REST API developement 1)
    tastypie Django REST framework API [Hello JSON]
    tastypie Django REST framework
    django admin.py settings 操作
    [修]开启MySQL远程访问权限 允许远程连接
    tmux tutorial
  • 原文地址:https://www.cnblogs.com/DDBD/p/13706015.html
Copyright © 2020-2023  润新知