小编Ste*_*ven的帖子

指定用于Keras Tensorflow模型推断的CPU

好的.我知道我们可以使用以下方法限制Keras(TF后端)模型使用的核心数量:

 K.set_session(K.tf.Session(config=K.tf.ConfigProto(intra_op_parallelism_threads=2, inter_op_parallelism_threads=2,  device_count = {'CPU': 2})))
Run Code Online (Sandbox Code Playgroud)

我们可以像这样指定单个张量运算:

with tf.device('/cpu:0'):
    a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
Run Code Online (Sandbox Code Playgroud)

但是,如果我们想要指定Keras模型使用的各个CPU列表呢?

python keras tensorflow

10
推荐指数
1
解决办法
225
查看次数

在Golang中使用Tensorflow中的嵌入层打开Keras模型

我正在尝试使用该tfgo包在Go中实现我的Keras神经网络.该模型包括2个常规输入和2个Keras嵌入层.它看起来像这样:

embedding_layer = Embedding(vocab_size,
                            100,
                            weights=[embedding_matrix],
                            input_length=100,
                            trainable=False)

sequence_input = Input(shape=(max_length,), dtype='int32')
embedded_sequences = embedding_layer(sequence_input)
text_lstm = Bidirectional(LSTM(256))(embedded_sequences)
text_lstm = Dropout(0.5)(text_lstm)
text_lstm  = Dense(512, activation='relu')(text_lstm )
text_lstm = Dropout(0.5)(text_lstm)
text_lstm  = Dense(256, activation='relu')(text_lstm)
text_lstm = Dropout(0.5)(text_lstm)
text_lstm  = Dense(128, activation='relu')(text_lstm)
text_lstm = Dropout(0.5)(text_lstm)

title_input = Input(shape=(max_title_length,), dtype='int32')
title_embed = Embedding(vocab_size, embedding_vector_length, input_length=max_title_length)(title_input)
title_lstm = Bidirectional(LSTM(128))(title_embed)
title_lstm = Dropout(0.5)(title_lstm)
title_lstm  = Dense(512, activation='relu')(title_lstm )
title_lstm = Dropout(0.5)(title_lstm)
title_lstm  = Dense(256, activation='relu')(title_lstm)
title_lstm = Dropout(0.5)(title_lstm)
title_lstm  = Dense(128, activation='relu')(title_lstm)
title_lstm …
Run Code Online (Sandbox Code Playgroud)

python go keras tensorflow

6
推荐指数
1
解决办法
320
查看次数

在 HTML 中使用 JSON 文件:Uncaught TypeError: data.forEach is not a function

我浏览了 web/docs,但找不到为什么这不起作用。

我正在尝试从 JSON 文件中插入数据(引号):{

"quotesArray":[{
    "personName": "Albert Einstein",
    "quote": "Look deep into nature, and then you will understand everything better."
},
{
    "personName": "Stephen Hawking",
    "quote": "Look deep into nature, and then you will understand everything better."
},
{
    "personName": "Confucius",
    "quote": "Life is really simple, but we insist on making it complicated."
}]}
Run Code Online (Sandbox Code Playgroud)

使用以下 JS 进入一个简单的 HTML div:

 $(document).ready(function() {
   $("#realquote").on("click", function() {
    $.getJSON('/json/quotes.json', function(data) {
     var html = " ";
       data.forEach(function(val) {
        var keys = Object.keys(val);
          html …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery json

4
推荐指数
1
解决办法
3万
查看次数

标签 统计

keras ×2

python ×2

tensorflow ×2

go ×1

html ×1

javascript ×1

jquery ×1

json ×1