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)
  • 相关阅读:
    ios开发--KVO浅析
    为iPhone6设计自适应布局
    详解iOS多线程 (转载)
    一些Iphone sqlite 的包装类
    ios多线程和进程的区别(转载)
    数据链路层解析
    物理层解析,交换机命令行
    计算机网络,数制模型
    java爬虫中jsoup的使用
    hadoop+zookeeper集群高可用搭建
  • 原文地址:https://www.cnblogs.com/DDBD/p/13706015.html
Copyright © 2011-2022 走看看