小编ami*_*ion的帖子

聚集函数在外行术语中对pytorch有什么作用?

我已经通过官方文件这个,但很难理解发生了什么.

我试图理解DQN源代码,它使用第197行的收集功能.

有人可以用简单的术语解释聚集函数的作用吗?这个功能的目的是什么?

pytorch

26
推荐指数
4
解决办法
2万
查看次数

如何在spring boot中创建Tcp Connection以接受连接?

我已经完成了这一点并理解我需要创建一个TcpReceivingChannelAdapter接受连接.但我不知道如何处理.

有人可以指导我吗?

java tcp spring-integration spring-boot

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

Spring Security中PreAuthenticatedAuthenticationToken的目的?

我正在使用SpringBoot中的UsernamePasswordAuthenticationToken对用户进行身份验证.

我正在为该用户使用JJWT生成令牌并将其返回.

现在,用户使用该令牌向我发送任何进一步的请求.在解密令牌后,我应该使用PreAuthenticatedAuthenticationToken并将其设置为SecurityContextHolder.getContext().setAuthentication()

目的是PreAuthenticatedAuthenticationToken什么?

java spring-security jwt spring-boot

12
推荐指数
1
解决办法
6013
查看次数

如何将spring-boot作为客户端应用程序运行?

我在一个应用程序中有2个主要入口点.

一个main启动服务器,映射控制器并启动一些工作线程.这些工作人员从云队列接收消息.

如果负载增加,我希望能够增加额外的工作来完成我的工作.所以我在我的应用程序中有第二个主要入口点,我希望能够在不启动 spring-boot(作为客户端应用程序)的默认服务器的情况下启动,以避免端口冲突(显然会导致失败).

我该如何实现这一目标?

java client-applications entry-point spring-boot

9
推荐指数
1
解决办法
8721
查看次数

无法在远程Linux VM上执行pg_restore SQL文件

我使用PostgreSQL作为我的数据库.

我已经SCPed一个.SQL在我的远程Ubuntu虚拟机文件.

我做了sudo su - postgres并创建了一个DB.

然后我切换到我的原始帐户并尝试这个:

sudo -su postgres pg_restore < temp.sql

该命令成功运行.

但当我再次切换回postgres用户并使用\ dt检查数据库中的表列表时,我发现没有表格.

我究竟做错了什么?

linux postgresql virtual-machine pg-restore

8
推荐指数
2
解决办法
9120
查看次数

Spring启动中/*和/**模式有什么区别?

当我注意到/*/**模式之间存在差异时,我试图为过滤器注册某些URL .

    @Bean
    public FilterRegistrationBean tokenAuthenticationFilterBean() {
        FilterRegistrationBean registration = new FilterRegistrationBean(tokenAuthenticationFilter);
        registration.addUrlPatterns("/api/**","/ping","/api/*");
        return registration;
    }
Run Code Online (Sandbox Code Playgroud)

这些模式有什么区别?

pattern-matching spring-boot

7
推荐指数
2
解决办法
4923
查看次数

下面这段代码的空间复杂度?

我在做一些面试准备时遇到了这个问题。

public class Main {
    public static void main(String[] args) {
        // n is some user input value
        int i = 0;
        while (i < n) {
            int[] a = new int[n];
            for (int j = 0; j < n; j++){
                a[j] = i * j;
            }
            i++;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

给出的选择是:

  1. 在)
  2. O(n^2)

据我所知,答案应该是 O(n),因为每次迭代都会创建一个新的数组实例,而之前的引用正在丢失。然而,书中提到答案是 O(n^2)。

什么是可能的解释?

java space-complexity

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

编译Angular 4应用程序"__webpack_require__"时出错

我刚刚开始学习Angular 4.我收到以下错误

Uncaught TypeError: Object(...) is not a function
    at eval (bidi.es5.js:70)
    at eval (bidi.es5.js:72)
    at Object../node_modules/@angular/cdk/esm5/bidi.es5.js (vendor.bundle.js:39)
    at __webpack_require__ (inline.bundle.js:55)
    at eval (core.es5.js:57)
    at Object../node_modules/@angular/material/esm5/core.es5.js (vendor.bundle.js:255)
    at __webpack_require__ (inline.bundle.js:55)
    at eval (autocomplete.es5.js:15)
    at Object../node_modules/@angular/material/esm5/autocomplete.es5.js (vendor.bundle.js:191)
    at __webpack_require__ (inline.bundle.js:55)
Run Code Online (Sandbox Code Playgroud)

还有一堆像这样的警告

./node_modules/@angular/material/esm5/datepicker.es5.js
107:59-75 "export 'defineInjectable' was not found in '@angular/core'
 @ ./node_modules/@angular/material/esm5/datepicker.es5.js
 @ ./node_modules/@angular/material/esm5/material.es5.js
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi (webpack)-dev-server/client?http://0.0.0.0:0 ./src/main.ts

./node_modules/@angular/cdk/esm5/a11y.es5.js
1118:164-170 "export 'inject' was not found in '@angular/core'
 @ ./node_modules/@angular/cdk/esm5/a11y.es5.js
 @ ./node_modules/@angular/material/esm5/bottom-sheet.es5.js
 @ ./node_modules/@angular/material/esm5/material.es5.js
 @ ./src/app/app.module.ts
 @ ./src/main.ts …
Run Code Online (Sandbox Code Playgroud)

angular-material2 angular

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

无法在Mac上测试Mosquitto服务器

我已经使用brew通过以下方式安装了Mosquitto

brew install mosquitto

并测试是否正在使用

brew services list

输出量

Name       Status  User Plist
mongodb    stopped      
mosquitto  started amit /Users/amit/Library/LaunchAgents/homebrew.mxcl.mosquitto.plist
postgresql stopped      
tomcat     stopped
Run Code Online (Sandbox Code Playgroud)

然而,当我尝试从以下这个答案,我得到命令没有找到

mosquitto_sub -v -t 'test/topic'
-bash: mosquitto_sub: command not found
Run Code Online (Sandbox Code Playgroud)

我是否需要安装其他东西才能工作?

另外,我尝试使用python脚本连接到代理,但收到连接被拒绝的消息

client = mqtt.Client()
client.on_connect = on_connect_handler
client.on_message = on_message_handler

client.connect("localhost", 1883, 60)
client.loop_forever()
Run Code Online (Sandbox Code Playgroud)

编辑1

我解决了无法使用mosquitto_subusing 的第一个问题brew link mosquitto

但是我仍然被拒绝连接。

macos mosquitto

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