zoukankan      html  css  js  c++  java
  • 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)
  • 相关阅读:
    定时器
    按键中断部分的理解
    初中数学
    WING IDE 快捷键
    机器学习各种网址
    SQL With As 用法Sql 四大排名函数(ROW_NUMBER、RANK、DENSE_RANK、NTILE)简介
    Python编码格式导致的csv读取错误
    Oracle中的rownum 和rowid的用法和区别
    oracle配置
    matplotlib命令与格式:标题(title),标注(annotate),文字说明(text)
  • 原文地址:https://www.cnblogs.com/DDBD/p/13706015.html
Copyright © 2011-2022 走看看