我的张量看起来像:
array([[[ 1, 2, 3],
[ 3, 4, 5]],
[[11, 22, 33],
[33, 44, 55]]], dtype=int32)
我想在内部数组中的每个索引处连接/堆叠值,如下所示:
array([[[1, 3], [2, 4], [3, 5]],
[[11, 33], [22, 44], [33, 55]]], dtype=int32)
我尝试了各种形式的tf.concat和tf.stack / tf.unstack,但似乎无法正确完成。有谁知道该怎么做?
答案 0 :(得分:2)
您可以使用@Bean
public IntegrationFlow heartbeatServerFlow(
TcpNetServerConnectionFactory serverConnectionFactory,
HeartbeatServer heartbeatServer) {
return IntegrationFlows
.from(Tcp.inboundGateway(serverConnectionFactory))
.handle(heartbeatServer::processRequest)
.get();
}
:
public class HeartbeatServer {
private final Logger log = LogManager.getLogger(HeartbeatServer.class);
public Message<String> processRequest(byte[] payload, MessageHeaders messageHeaders) {
String messageStr = new String(payload);
if (messageStr.equals("status")) {
log.info("Heartbeat received");
return new GenericMessage<>("OK");
} else {
log.error("Unexpected message content from client: " + messageStr);
return null;
}
}
}