我无法理解tf.nn.dynamic_rnntensorflow函数的输出.该文档只是告诉输出的大小,但它没有说明每行/列的含义.从文档:
输出:RNN输出
Tensor.如果time_major == False(默认),这将是一个
Tensor形状:[batch_size, max_time, cell.output_size].如果time_major == True,这将是一个
Tensor形状:[max_time, batch_size, cell.output_size].注意,如果
cell.output_size是整数或TensorShape对象的(可能是嵌套的)元组,那么outputs将是具有
与cell.output_size包含与形状数据对应的形状的张量的具有相同结构的元组cell.output_size.州:最终状态.如果
cell.state_size是int,则会形成[batch_size, cell.state_size].如果它是
TensorShape,这将形成[batch_size] + cell.state_size.
如果它是一个(可能是嵌套的)int的元组TensorShape,那么这将是一个具有相应形状的元组.
的outputs张量是3 d矩阵但到底是什么每行/列表示?
我在tensorflow中创建了一个暹罗网络.我正在使用以下代码计算两个张量之间的距离:
distance = tf.sqrt(tf.reduce_sum(tf.square(tf.subtract(question1_predictions, question2_predictions)), reduction_indices=1))
Run Code Online (Sandbox Code Playgroud)
我能够毫无错误地训练模型.在推理部分,我正在检索distance张量,如下所示:
test_state, distance = sess.run([question1_final_state, distance], feed_dict=feed)
Run Code Online (Sandbox Code Playgroud)
Tensorflow抛出错误:
Fetch参数数组([....],dtype = float32)具有无效类型,必须是字符串或Tensor.(无法将ndarray转换为Tensor或Operation.)
当我在训练部分distance之前和之后打印张量时session.run,它显示为<class 'tensorflow.python.framework.ops.Tensor'>.所以在推理部分发生distance了numpy 的张量替换.遵循推理部分的代码:distancesession.run
with graph.as_default():
saver = tf.train.Saver()
with tf.Session(graph=graph) as sess:
sess.run(tf.global_variables_initializer(), feed_dict={embedding_placeholder: embedding_matrix})
saver.restore(sess, tf.train.latest_checkpoint('checkpoints'))
test_state = sess.run(initial_state)
for ii, (x1, x2, batch_test_ids) in enumerate(get_test_batches(test_question1_features, test_question2_features, test_ids, batch_size), 1):
feed = {question1_inputs: x1,
question2_inputs: x2,
keep_prob: 1,
initial_state: test_state
}
test_state, distance = sess.run([question1_final_state, distance], feed_dict=feed)
Run Code Online (Sandbox Code Playgroud) 我们可以通过右键单击表格并选择“表格属性”来手动设置 Google Docs 中表格的左缩进:
我尝试通过设置INDENT_FIRST_LINE和INDENT_START属性使用 Google Apps Script 实现相同的目的,但对表没有影响:
var style = {};
style[DocumentApp.Attribute.INDENT_FIRST_LINE] = 72;
style[DocumentApp.Attribute.INDENT_START] = 72;
body.insertTable(elementIndex, table).setAttributes(style);
Run Code Online (Sandbox Code Playgroud)
如何使用 Google Apps 脚本为表设置相同的属性?有没有其他方法可以实现相同的目标?
请在此问题上加注星标,以便 Google 团队优先处理:
我有简单的状态机跟随States,Events和Transitions.
状态: WIP, SUBMITTED, REJECTED, APPROVED
事件: SUBMIT, APPROVE, REJECT
转变:
@Override
public void configure(StateMachineTransitionConfigurer<States,Events> transitions)
throws Exception {
transitions
.withExternal()
.source(States.WIP)
.target(States.SUBMIT)
.event(Events.SUBMIT)
.and()
.withExternal()
.source(States.SUBMITTED)
.target(States.APPROVED)
.event(Events.APPROVE)
.and()
.withExternal()
.source(States.SUBMITTED)
.target(States.REJECTED)
.event(Events.REJECT);;
}
Run Code Online (Sandbox Code Playgroud)
我已将WIP初始状态设置如下:
@Override
public void configure(StateMachineStateConfigurer<States, Events> states)
throws Exception {
states
.withStates()
.initial(States.WORK_IN_PROGRESS)
.states(EnumSet.allOf(States.class));
}
Run Code Online (Sandbox Code Playgroud)
多个用户将与此状态机进行交互.当源和目标状态的组合多次引发相同的事件时,状态机仅接受第一个事件,不接受后续事件.
这是状态机的有效行为吗?如果是,是否需要添加任何额外配置?
I have a scenario wherein the user uploads a file to the system. The only file that the system understands in a CSV, but the user can upload any type of file eg: jpeg, doc, html. I need to throw an exception if the user uploads anything other than CSV file.
Can anybody let me know how can I find if the uploaded file is a CSV file or not?
我们使用 Google Drive v3 API 来管理 Web 应用程序中的文档。我们有一个简单的用例,其中用户单击按钮,后端需要从文件夹复制大约 5-10 个source文件destination。我已经对源文件夹中的 6 个文件进行了测试,API 花费了大约 7 秒。我使用批处理来调用复制文件 API。以下是相同的代码:
将请求添加到队列:
for(Template template: templates) {
File file = new File();
file.setParents(Collections.singletonList(parentFileId));
file.setName(template.getName());
file.setWritersCanShare(false);
file.setViewersCanCopyContent(false);
Map<String, String> appProperties = new HashMap<>();
appProperties.put(TEMPLATE_CODE_PROP_NAME, template.getCode());
file.setAppProperties(appProperties);
driveService.files().copy(template.getFileId(), file)
.setFields("id, name, appProperties, webViewLink, iconLink, mimeType")
.queue(batch, callback);
}
Run Code Online (Sandbox Code Playgroud)
批处理执行成功后处理响应:
JsonBatchCallback<File> callback = new JsonBatchCallback<File>() {
@Override
public void onSuccess(File file, HttpHeaders responseHeaders) throws IOException {
log.info("Copied file successfully - " + file.getName() + " …Run Code Online (Sandbox Code Playgroud) 我创建了一个 Apps 脚本来替换 Google Doc 中的令牌。此应用程序脚本已部署为 API 可执行文件。我能够在没有任何授权错误的情况下在应用程序脚本编辑器中运行一个函数。但是,当从我的 Java Web 应用程序调用时,它有时会因授权错误而失败。我收到以下错误:
{
"name": "replaceTokensInDoc",
"done": true,
"error": {
"code": 3,
"message": "ScriptError",
"details": [
{
"@type": "type.googleapis.com/google.apps.script.v1.ExecutionError",
"errorMessage": "Authorization is required to perform that action.",
"errorType": "ScriptError"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
我在多个地方读到我只需要在脚本编辑器中运行一个函数并提供解决这个问题的权限,但这对我来说没有帮助。当我在编辑器中运行一个函数时,它甚至不显示授权对话框,这意味着它具有所有必要的权限。它只是有时会失败。有人可以让我知道这种奇怪行为的原因吗?
我想将Java对象转换为包含封送的XML数据的String.我找到的方法之一是首先编组一个文件然后使用BufferedReader读取文件以转换为字符串.我觉得这可能不是最有效的方法,因为IO操作执行两次(一次是在封送期间,另一次是在将文件内容转换为String期间)
有人可以建议任何更好的方法吗?
我有两个在 Google App Engine 上运行的服务(MS1 和 MS2)。MS1 部署在标准环境中,MS2 部署在灵活环境中。我正在从标准环境调用 API 到灵活环境。我想确保 MS2 只接受来自 MS1 的请求。所以,我决定使用App Engine 的这个功能。我正在MS1 中设置X-Appengine-Inbound-Appid标头和setInstanceFollowRedirectsto false,但看起来 App Engine 正在删除此标头。我在 MS2 中找不到这个标题。
HttpHeaders headers = new HttpHeaders();
headers.add("X-Appengine-Inbound-Appid", ApiProxy.getCurrentEnvironment().getAppId());
HttpEntity<MergePdfsResource> entity = new HttpEntity<MergePdfsResource>(mergePdfsResource, headers);
restTemplate.setRequestFactory(new SimpleClientHttpRequestFactory() {
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
super.prepareConnection(connection, httpMethod);
connection.setInstanceFollowRedirects(false);
}
});
ResponseEntity<SomeClass> response = restTemplate.postForEntity(apiUrl, entity, SomeClass.class);
Run Code Online (Sandbox Code Playgroud) google-app-engine spring spring-restcontroller spring-rest google-flexible
java ×2
spring ×2
tensorflow ×2
csv ×1
jaxb ×1
marshalling ×1
numpy ×1
python ×1
spring-rest ×1