问题列表 - 第251182页

从 3rd 方源恢复 NuGet 包

我尝试使用命令行nuget来恢复 NuGet 包,例如:

nuget restore BuptAssistant.sln
Run Code Online (Sandbox Code Playgroud)

但我使用了第三个 NuGet 包源中的一些包。在 Visual Studio 中,我可以使用Options - NuGet Package Manager - Package sources命令行设置另一个包源,该怎么做?

Travis CI中可以看到错误日志

.net mono visual-studio nuget travis-ci

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

我是否在k-fold cross_validation中使用相同的Tfidf词汇表

我正在进行基于TF-IDF向量空间模型的文本分类.我只有不超过3000个样本.为了公平评估,我正在使用5倍交叉验证来评估分类器.但令我困惑的是,是否有必要TF-IDF在每个折叠交叉验证中重建向量空间模型.也就是说,我是否需要重建词汇表并重新计算IDF每个折叠交叉验证中的词汇量值?

目前我正在基于scikit-learn工具包进行TF-IDF转换,并使用SVM训练我的分类器.我的方法如下:首先,我将手中的样本除以3:1的比例,75%的样本用于拟合TF-IDF向量空间模型的参数.Herein,参数是大小词汇及其中包含的术语,也是IDF词汇中每个术语的价值.然后我在这里转换剩余部分TF-IDF SVM并使用这些向量进行5倍交叉验证(值得注意的是,我不使用之前的75%的样本用于转化).

我的代码如下:

# train, test split, the train data is just for TfidfVectorizer() fit
x_train, x_test, y_train, y_test = train_test_split(data_x, data_y, train_size=0.75, random_state=0)
tfidf = TfidfVectorizer()
tfidf.fit(x_train)

# vectorizer test data for 5-fold cross-validation
x_test = tfidf.transform(x_test)

 scoring = ['accuracy']
 clf = SVC(kernel='linear')
 scores = cross_validate(clf, x_test, y_test, scoring=scoring, cv=5, return_train_score=False)
 print(scores)
Run Code Online (Sandbox Code Playgroud)

我的困惑在于,我的方法是进行TF-IDF转换和进行5倍交叉验证是否正确,或者是否有必要TF-IDF使用列车数据重建矢量模型空间,然后转换为TF-IDF包含列车和测试数据的向量?如下:

skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=0)
for train_index, test_index in …
Run Code Online (Sandbox Code Playgroud)

python tf-idf scikit-learn cross-validation

8
推荐指数
1
解决办法
1152
查看次数

SVG图像加载缓慢或持续在站点中

我在网站上有几个SVG背景。它们的大小小于50kb,但是加载速度很慢,或者它们似乎是网站上的最后一个元素。由于它们位于页面的页眉上,因此在加载图像时我不需要空格。我一直在尝试寻找答案或原因,以解决此问题并优化svg,但似乎找不到解决方案。我的背景为白色约2-3秒,然后出现SVG。

我正在CSS中内联加载SVG

这就是我的HTML

<div class='header-main'>
  <div class="header">
    <hr></hr>
    <h1 class="tagline">Some Text</h1>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

加载SVG的CSS为:

.header-main {
  background: url('{{ asset "/img/background-main.svg"}}');
}
Run Code Online (Sandbox Code Playgroud)

html css svg

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

Rails:BCrypt::Errors::InvalidHash(无效哈希)Devise 1.5.4 Rails 2.2.5

我们在 devise.rb 中使用以下内容

config.encryptor = :bcrypt
Run Code Online (Sandbox Code Playgroud)

我们想将其更改为

config.encryptor = :authlogic_sha512
Run Code Online (Sandbox Code Playgroud)

还编写了代码来解密旧密码并在登录时将其哈希为新密码(在会话控制器内)

但是,更新密码后,注销并登录时出现错误

BCrypt::Errors::InvalidHash (invalid hash):
Run Code Online (Sandbox Code Playgroud)

如果我注释掉错误的原始点,此错误会随机出现。所以我认为设备配置或 user.rb 模型有问题。

用户模型有以下行:

devise :database_authenticatable, :registerable, :confirmable,
     :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :omniauth_providers => [:auth0, :google_oauth2]
Run Code Online (Sandbox Code Playgroud)

所以步骤顺序是这样的:

  1. 用户的信息位于数据库(现有用户)中。使用 bcrypt 加密的密码
  2. 用户登录并在会话控制器中,我们将密码重新哈希为 sha512 并将其存储在 crypto_password 字段中
  3. 用户退出
  4. 用户登录 *** 由于“invalid_hash”错误而无法登录。

知道这里可能有什么问题吗?提前致谢。

编辑:根据要求执行上述步骤 2 的代码:

class Users::SessionsController < Devise::SessionsController
...
...
email = params[:user]['login']

@user = User.find_by_email(email)
return if @user.nil?
# Get old password and salt
bcrypt = BCrypt::Password.new(@user.encrypted_password)
salt = bcrypt.salt

pwd = params[:user]['password']

pass …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails devise ruby-on-rails-3

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

模块“xgboost”没有属性“DMatrix”

我提取了一些在 kaggle (linux) 上运行的 ML 代码,并尝试在 Windows 机器上的 jupyter notebook 中运行它。这是代码(其中一些):

##### RUN XGBOOST
import xgboost as xgb

print("\nSetting up data for XGBoost ...")
# xgboost params
xgb_params = {
    'eta': 0.037,
    'max_depth': 5,
    'subsample': 0.80,
    'objective': 'reg:linear',
    'eval_metric': 'mae',
    'lambda': 0.8,   
    'alpha': 0.4, 
    'base_score': y_mean,
    'silent': 1
}

#### These lines were causing the folloing error on 9/1/2017:
# AttributeError: module 'xgboost' has no attribute 'DMatrix'
dtrain = xgb.DMatrix(x_train.values, y_train.values)
dtest = xgb.DMatrix(x_test)

num_boost_rounds = 250
print("num_boost_rounds="+str(num_boost_rounds))

# train …
Run Code Online (Sandbox Code Playgroud)

python machine-learning xgboost

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

基于引用来限制对AWS S3存储桶的访问

我正在尝试限制对S3存储桶的访问,并且只允许基于引用者的列表中的某些域.

存储桶策略基本上是:

{
"Version": "2012-10-17",
"Id": "http referer domain lock",
"Statement": [
    {
        "Sid": "Allow get requests originating from specific domains",
        "Effect": "Allow",
        "Principal": "*",
        "Action": "s3:GetObject",
        "Resource": "arn:aws:s3:::example.com/*",
        "Condition": {
            "StringLike": {
                "aws:Referer":  [ 
                    "*othersite1.com/*",
                    "*othersite2.com/*",
                    "*othersite3.com/*"
                ]
            }
        }
    }
 ]
}
Run Code Online (Sandbox Code Playgroud)

这个otherite1,2和3调用一个对象,我已经存储在域example.com下的s3存储桶中.我还有一个附加到存储桶的云端分发.我在字符串条件之前和之后使用*通配符.引用者可以是othersite1.com/folder/another-folder/page.html.引用者也可以使用http或https.

我不知道为什么我得到403 Forbidden错误.

我这样做基本上是因为我不希望其他网站调用该对象.

任何帮助将不胜感激.

policy amazon-s3 amazon-web-services amazon-cloudfront

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

使用goroutines处理值并将结果收集到切片中

我最近正在探索Go,goroutines如何工作使我感到困惑。

我尝试使用goroutines将之前编写的代码移植到Go中,但出现fatal error: all goroutines are asleep - deadlock!错误。

我正在尝试使用goroutines处理列表中的项目,然后将处理后的值收集到新列表中。但是我在“聚会”部分遇到了问题。

码:

sampleChan := make(chan sample)
var wg sync.WaitGroup

// Read from contents list
for i, line := range contents {
    wg.Add(1)
    // Process each item with a goroutine and send output to sampleChan
    go newSample(line, *replicatePtr, *timePtr, sampleChan, &wg)
}
wg.Wait()

// Read from sampleChan and put into a slice
var sampleList []sample
for s := range sampleChan {
    sampleList = append(sampleList, s)
}
close(sampleChan)
Run Code Online (Sandbox Code Playgroud)

从goroutine收集结果的正确方法是什么?

我知道切片不是线程安全的,所以我不能让每个goroutine仅追加到切片中。

go slice goroutine

5
推荐指数
2
解决办法
2112
查看次数

检测使用指令单击角度4中的外部元素

我已经使用自定义指令来检测角度2中元素外部的单击,但角度4中不可能相同.

[plunkr] https://plnkr.co/edit/aKcZVQ?p=info

当我尝试在angular-4中使用相同的代码时,我收到以下错误:

1. Argument of type '{ template: string; directives: typeof ClickOutside[]; }' is not assignable to parameter of type 'Component'. ==> 

    @Component({
    templateUrl: "",
    directives: [ClickOutside]
    })


2. Type 'Subscription' is not assignable to type 'Observable<MouseEvent>'. in the directive inside ngOnInit() and ngOnDestroy() 

ngOnInit() {
    this.globalClick = Observable
        .fromEvent(document, 'click')
        .delay(1)
        .do(() => {
            this.listening = true;
         }).subscribe((event:MouseEvent) => {
            this.onGlobalClick(event);
         });
}

ngOnDestroy() {
    this.globalClick.unsubscribe();
}
Run Code Online (Sandbox Code Playgroud)

如果角度4中的指令声明有任何变化请告诉我,官方文档对此事没有任何帮助.

angular-directive angular2-directives angular angular-observable

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

瘦,f*和dafny有什么区别?

他们来自微软,看起来像是助理?除了语法差异之外,还有哪些实际方面使它们彼此不同(比如说能够做自动化,表达能力等)?我是正式验证的新手.

编辑:我不是要求哪一个更好,我只是对这些工具提供的不同功能之间的技术比较感兴趣.我正在寻找像这样

dafny lean fstar

13
推荐指数
1
解决办法
1460
查看次数

如何使用webpack与monorepo(yarnpkg工作区)

我正在使用 纱线工作区,其中根目录具有包含所有我的存储库的包目录.每个repo都有自己的node_modules目录,其中包含其依赖项.根node_modules目录包含整个项目的所有dev依赖项以及所有其他dev相关的东西,例如webpack.config文件.Webpack使用热模块重新加载Express服务器包.

我遇到的问题是,如何配置webpack外部以通过整个项目排除所有node_modules目录,而不仅仅是在根目录中?

在这种情况下,webpack-node-externals似乎不起作用.

错误信息:

WARNING in ./packages/servers/express/node_modules/colors/lib/colors.js
127:29-43 Critical dependency: the request of a dependency is an expression

WARNING in ./packages/servers/express/node_modules/express/lib/view.js
79:29-41 Critical dependency: the request of a dependency is an expression
Run Code Online (Sandbox Code Playgroud)

Webpack配置:

const webpack = require('webpack');
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const StartServerPlugin = require('start-server-webpack-plugin');

module.exports = {
  entry: [
    'babel-polyfill',
    'webpack/hot/poll?1000',
    path.join(__dirname, '../packages/servers/express/server/index.js')
  ],
  watch: true,
  target: 'node',
  externals: [
    nodeExternals({
      whitelist: ['webpack/hot/poll?1000']
    })
  ],
  resolve: {
    alias: {
      handlebars: 'handlebars/dist/handlebars.js' …
Run Code Online (Sandbox Code Playgroud)

node.js express webpack yarnpkg

19
推荐指数
3
解决办法
6733
查看次数