小编don*_*lan的帖子

AWS错误:Url验证期间出错; 检查网址,然后重试

在此输入图像描述我正在尝试通过visual studio的工具包将测试站点部署到AWS,我在环境选择页面上遇到了一个奇怪的错误.谷歌搜索没有提供真正的信息.

当我尝试验证网址选择时出现错误.它说:"URL验证期间出错;请检查URL并重试." 我把网址改为我能想到的一切,没有运气.当我点击下一步时,无论URL是什么,都会出现一个消息框,通知我该URL不可用.有没有办法解决这个错误?

amazon-web-services amazon-elastic-beanstalk

14
推荐指数
2
解决办法
4571
查看次数

MemoryStream to String,并返回MemoryStream而不添加任何字节(编码等)

好的,我在这里这里都遇到过一些文章,但他们并没有做我需要做的事情,而且我遇到了一些麻烦.

我收到一段加密的数据作为内存流.我需要以某种方式将内存流写入文件(我编写模型的方式,因为字符串最好),然后从文件中检索字符串并将其作为内存流发送到要解密的服务.我只是使用流读取器将内存流存储为字符串,并使用编码将字符串读入内存.

问题是我收到一个错误,说我的加密数据已损坏.我认为这意味着我以某种方式改变了字节.

以下是将memorystream读入字符串的代码:

using (StreamReader reader = new StreamReader(dataKeyResponse.CiphertextBlob))
{
    encryptedDataKey = reader.ReadToEnd();
}
Run Code Online (Sandbox Code Playgroud)

以下是将从文件中检索到的字符串读取到内存流中的代码:

MemoryStream mStream = new MemoryStream(ASCIIEncoding.Default.GetBytes(encryptedKey));
Run Code Online (Sandbox Code Playgroud)

我认为这样做的步骤是ASCIIEncoding,但后来我实现了上面的解决方法,将字节数组转换为内存流,并得到了同样的错误.

byte[] bytes = new byte[encryptedKey.Length*sizeof (char)];
System.Buffer.BlockCopy(encryptedKey.ToCharArray(), 0, bytes, 0, bytes.Length);

string decryptedKey;
using (MemoryStream mStream = new MemoryStream())
{
    mStream.Write(bytes, 0, bytes.Length);
    var decryptRequest = new DecryptRequest()
    {CiphertextBlob = mStream};
    var decryptResponse = client.Decrypt(decryptRequest);
    using (StreamReader reader = new StreamReader(decryptResponse.Plaintext))
    {
        decryptedKey = reader.ReadToEnd();
    }
}
Run Code Online (Sandbox Code Playgroud)

我假设(1)有些东西以某种方式改变数据而不是其他一些错误; (2)它在流 - >字符串或字符串 - …

c# arrays string encryption

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

BASH:转义字符串

假设我有以下字符串:

"some\nstring\n..."
Run Code Online (Sandbox Code Playgroud)

当在 bash 中 catted 时,它显示为一行。更远,

string_from_pipe | sed 's/\\\\/\\/g' # does not work
| awk '{print $0}'
| awk '{s = $0; print s}'
| awk '{s = $0; printf "%s",s}'
| echo $0  
| sed 's/\\(.)/\1/g'
# all have not worked. 
Run Code Online (Sandbox Code Playgroud)

我如何取消转义这个字符串,使其打印为:

some
string
Run Code Online (Sandbox Code Playgroud)

或者甚至在文件中以这种方式显示?

bash

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

Sklearn SVM:SVR和SVC,为每个输入获得相同的预测

这是代码的粘贴:SVM示例代码

我查看了这个问题的几个其他答案......似乎问题的这个特定迭代有点不同.

首先,我的输入被标准化,我每点有五个输入.这些值都是合理的大小(健康的0.5s和0.7s等 - 很少接近零或接近1个数字).

我有大约70个输入对应于他们的70 y输入.y输入也被标准化(它们是每个时间步之后我的函数的百分比变化).

我初始化我的SVR(和SVC),训练它们,然后用30个样本外输入测试它们......并获得每个输入的完全相同的预测(并且输入正在以合理的量变化 - 0.3,0.6 ,0.5等).我认为分类器(至少)会有一些区别......

这是我得到的代码:

# train svr

my_svr = svm.SVR()
my_svr.fit(x_training,y_trainr)

# train svc

my_svc = svm.SVC()
my_svc.fit(x_training,y_trainc)


# predict regression

p_regression = my_svr.predict(x_test)
p_r_series = pd.Series(index=y_testing.index,data=p_regression)

# predict classification

p_classification = my_svc.predict(x_test)
p_c_series = pd.Series(index=y_testing_classification.index,data=p_classification)
Run Code Online (Sandbox Code Playgroud)

以下是我输入的示例:

x_training = [[  1.52068627e-04   8.66880301e-01   5.08504362e-01   9.48082047e-01
7.01156322e-01],
              [  6.68130520e-01   9.07506250e-01   5.07182647e-01   8.11290634e-01
6.67756208e-01],
              ... x 70 ]

y_trainr = [-0.00723209 -0.01788079  0.00741741 -0.00200805 -0.00737761  0.00202704 ...]

y_trainc = [ 0.  0.  1.  0. …
Run Code Online (Sandbox Code Playgroud)

python scikit-learn sklearn-pandas

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

无论顺序如何,都可以在python列表中获取唯一的元组

我有一个python列表:

[ (2,2),(2,3),(1,4),(2,2), etc...]
Run Code Online (Sandbox Code Playgroud)

我需要的是某种功能,将其减少为其独特的组件......在上面的列表中:

[ (2,2),(2,3),(1,4) ]
Run Code Online (Sandbox Code Playgroud)

numpy unique并不是这么做的.我可以想办法做到这一点 - 将我的元组转换为数字,[22,23,14,etc.]找到唯一的,并从那里开始工作......但我不知道复杂性是否会失控.是否有一个函数可以完成我尝试用元组做的事情?


以下是演示此问题的代码示例:

 import numpy as np

 x = [(2,2),(2,2),(2,3)]
 y = np.unique(x)
Run Code Online (Sandbox Code Playgroud)

回报:y:[2 3]

以下是演示修复的解决方案的实现:

 x = [(2,2),(2,2),(2,3)]
 y = list(set(x))
Run Code Online (Sandbox Code Playgroud)

返回y:[(2,2),(2,3)]

python numpy list duplicates

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

安装 GNU-Parallel:如何从 docker build 输入“will cite”?

在泊坞窗文件中:

from debian:latest

RUN apt-get install parallel
RUN parallel --citation <<< "will cite" 
Run Code Online (Sandbox Code Playgroud)

而docker构建根本就因为这个进入过程而没有完成。如何并联安装?

gnu-parallel docker

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

NumPy Broadcasting:计算两个数组之间的平方差之和

我有以下代码.它永远在Python中.必须有办法将此计算转换为广播......

def euclidean_square(a,b):
    squares = np.zeros((a.shape[0],b.shape[0]))
    for i in range(squares.shape[0]):
        for j in range(squares.shape[1]):
            diff = a[i,:] - b[j,:]
            sqr = diff**2.0
            squares[i,j] = np.sum(sqr)
    return squares
Run Code Online (Sandbox Code Playgroud)

python numpy numpy-broadcasting

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

TensorFlow:Hadamard产品::我如何得到这个?

Tensorflow具有以下功能:

tf.matmul
Run Code Online (Sandbox Code Playgroud)

它将两个向量相乘并产生一个标量.

但是,我需要做以下事情:

# dense dim:  (?,227)
dense_part = tf.nn.relu(some stuff here)

# softmax matrix dim: (?,227,19) or (?,19,227) or (?,227,227), where I 
# ....can slice the last dim down to (?,227,19)
softmax_matrix = tf.matmul(dense_part,softmax_weight_variable)
Run Code Online (Sandbox Code Playgroud)

但是,为了通过矩阵乘法实现这一点,我无法设置softmax_weight_variable.我需要使用"Tensor Product"(也称为"Outer Product"......),但这个功能似乎没有实现.

如何在TensorFlow中实现Hadamard(元素方式)乘法和外积?

python tensorflow

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

Python:带有列表列表的 Argparse

最小可验证示例:

import argparse

parser = argparse.ArgumentParser(description='...')
parser.add_argument('-f','--file', type=str, nargs='+', help='file list')

args = parser.parse_args()

print(args.sparse[:])
Run Code Online (Sandbox Code Playgroud)

这个想法是我称之为:

python my_script.py -f f1 f2 f3 -f some_other_file1 some_other_file2 ...
Run Code Online (Sandbox Code Playgroud)

输出将是:

[ [ f1 f2 f3 ] [ some_other_file1 some_other_file2 ] ]
Run Code Online (Sandbox Code Playgroud)

但是,在这种情况下,打印出来的只是:

 [ some_other_file1 some_other_file2 ]
Run Code Online (Sandbox Code Playgroud)

python argparse

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

如何使用 pip 在可编辑模式下安装 setup.cfg + pyproject.toml python 项目?

是否可以将蛋糕减半并吃掉它:可以安装(通过某种机制)具有以下结构的项目:

pyproject.toml
setup.cfg
src/...
scripts/...
Run Code Online (Sandbox Code Playgroud)

在可编辑模式下,就像使用标准setup.py项目一样:

python3 -m pip install -e . 
Run Code Online (Sandbox Code Playgroud)

(如果答案是:“ one does not install pyproj.toml packages in editable mode ”也可以)

setuptools python-packaging pyproject.toml pep517

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