小编wmI*_*Ibb的帖子

将 seq2seq 模型的 TF 1.0 sampled_softmax_loss 函数重新实现为 TF 2 Keras 模型

我有一个 seq2seq 模型的 TF 1.0.1 代码。我正在尝试使用 Tensorflow Keras 重写它。

TF 1.0.1 代码具有以下解码器架构:

with tf.variable_scope("decoder_scope") as decoder_scope:

    # output projection
    # we need to specify output projection manually, because sampled softmax needs to have access to the the projection matrix 

    output_projection_w_t = tf.get_variable("output_projection_w", [vocabulary_size, state_size], dtype=DTYPE)
    output_projection_w = tf.transpose(output_projection_w_t)
    output_projection_b = tf.get_variable("output_projection_b", [vocabulary_size], dtype=DTYPE)
    
    decoder_cell = tf.contrib.rnn.LSTMCell(num_units=state_size)
    decoder_cell = DtypeDropoutWrapper(cell=decoder_cell, output_keep_prob=tf_keep_probabiltiy, dtype=DTYPE)
    decoder_cell = contrib_rnn.MultiRNNCell(cells=[decoder_cell] * num_lstm_layers, state_is_tuple=True)   
    
    # define decoder train netowrk
    decoder_outputs_tr, _ , _ = dynamic_rnn_decoder( 
        cell=decoder_cell, 
        decoder_fn= …
Run Code Online (Sandbox Code Playgroud)

python nlp keras tensorflow

9
推荐指数
0
解决办法
193
查看次数

如何更正 spring boot 应用程序的类路径,使其包含单个兼容版本的 javax.persistence.PersistenceContext?

我正在尝试向我的 spring 启动应用程序添加一个参与者存储库接口(它实现了 CrudRepository)。但是这个接口的基本代码在运行时报错,说必须更正应用程序的类路径。我该怎么做,是否还有其他修改可以正确运行代码?

//参与者类

package com.example.spring2.participants;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.List;

@Entity
public class Participant {

    @Id
    private String name;
    private int age;
    private String job;

    @Autowired
    private ParticipentService participentService;

    public Participant() {
    }

    public Participant(String name, int age, String job) {
        this.name = name;
        this.age = age;
        this.job = job;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age; …
Run Code Online (Sandbox Code Playgroud)

java spring-data-jpa spring-boot

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

使用 Zookeeper 进行 Java 领导者选举

我读到了有关使用 Zookeeper 实现 Java 领导者选举的内容。我很清楚这里描述的算法。但我有一个关于算法的微妙问题要问。

在所解释的算法中,节点选择“/election”节点的所有子节点,并选择最小的节点作为领导者。

在这种情况下,他们如何决定哪些节点在,哪些不在。我想知道什么条件决定阻止一个迟到的节点创建其子节点并参与领导者选举。是不是超时了?如果是的话,如何以及在哪里计算?

java apache-zookeeper leader-election

2
推荐指数
1
解决办法
3640
查看次数