小编Dom*_*que的帖子

AttributeError:'Series'对象没有属性'reshape'

我正在使用sci-kit学习线性回归算法.在缩放Y目标功能的同时:

Ys = scaler.fit_transform(Y)
Run Code Online (Sandbox Code Playgroud)

我有

ValueError:预期的2D数组,改为获得1D数组:

之后我改编成使用:

Ys = scaler.fit_transform(Y.reshape(-1,1))
Run Code Online (Sandbox Code Playgroud)

但又得到了错误:

AttributeError:'Series'对象没有属性'reshape'

所以我检查了pandas.Series文档页面,它说:

reshape(*args,**kwargs) 从版本0.19.0开始不推荐使用.

python attributeerror reshape python-3.x pandas

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

如何在 Azure Pipelines yaml 中添加手动干预步骤

如何将手动干预步骤添加到多阶段 Azure Devops YAML 管道中?

在詹金斯你可以做一些事情:

stage ('approve-prod') {
    steps {
        input "Approve deployment to production?"
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在寻找 Azure Devops YAML 中的等效项。

注意:这是针对新发布的多阶段 Azure Devops 管道,而不是旧式发布管道。相关公告在这里https://devblogs.microsoft.com/devops/whats-new-with-azure-pipelines/

azure-devops azure-pipelines

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

Apache Flink:java.lang.NoClassDefFoundError

我正在尝试遵循此示例,但是当我尝试编译它时,出现此错误:

Error: Unable to initialize main class com.amazonaws.services.kinesisanalytics.aws
Caused by: java.lang.NoClassDefFoundError: org/apache/flink/streaming/api/functions/source/SourceFunction
Run Code Online (Sandbox Code Playgroud)

错误是由于此代码:

    private static DataStream<String> createSourceFromStaticConfig(StreamExecutionEnvironment env) {
        Properties inputProperties = new Properties();
        inputProperties.setProperty(ConsumerConfigConstants.AWS_REGION, region);
        inputProperties.setProperty(ConsumerConfigConstants.STREAM_INITIAL_POSITION, "LATEST");

        return env.addSource(new FlinkKinesisConsumer<>(inputStreamName, new SimpleStringSchema(), inputProperties));
    }
Run Code Online (Sandbox Code Playgroud)

我想这是有问题的线路:

  return env.addSource(new FlinkKinesisConsumer<>(inputStreamName, new SimpleStringSchema(), inputProperties));
Run Code Online (Sandbox Code Playgroud)

这是我的 Maven 依赖项:

在此处输入图片说明

可能有什么问题?任何依赖项,版本?

注意:如果我评论有问题的行,程序运行没有问题。

POM文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>as</groupId>
    <artifactId>a</artifactId>
    <version>1</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <geotools.version>21-SNAPSHOT</geotools.version>
        <java.version>1.8</java.version>
        <scala.binary.version>2.11</scala.binary.version>
        <flink.version>1.6.2</flink.version>
        <kda.version>1.0.1</kda.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target> …
Run Code Online (Sandbox Code Playgroud)

java intellij-idea noclassdeffounderror amazon-web-services apache-flink

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

为什么提高精度会使这个程序更快?

我在Project Euler上解决问题26,我需要计算1/n的重复部分的长度,其中n是1到1000之间的所有整数,并且看哪个数字是最长的重复部分.这意味着我需要更精确地完成我的部门.所以我通过更改来调整我的小数精度getContext().prec,但是以某种方式提高精度使程序更快.我使用Python 3.7运行了这个程序.这是代码:

import re
import time
s = time.time()
from decimal import *
getcontext().prec = 500 #This part
recurring = 0
answer = 0
p = re.compile(r"([0-9]+?)\1{3,}")
for i in range(1, 1000):
    f = p.search(str(Decimal(1) / Decimal(i))[5:])
    if f:
        number = f.group(1)
        if len(str(number)) > len(str(recurring)):
            recurring = number
            answer = i

print(answer)
print(time.time() - s)
Run Code Online (Sandbox Code Playgroud)

这是我使用500的精度时的结果:

>>> print(answer)
349
>>> print(time.time() - s)
2.923844575881958
Run Code Online (Sandbox Code Playgroud)

......这就是我使用5000的精度时得到的:

>>> print(answer)
983
>>> print(time.time() - s)
0.07812714576721191
Run Code Online (Sandbox Code Playgroud)

我用500交换500,不仅因为1/answer的重复部分可能超过500而给了我正确的答案,但它也快得多.我用在线Python解释器试过这个,它也给了我类似的结果.为什么会这样?

python performance python-3.x

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

FileNotFoundError: [WinError 2] 系统找不到指定的文件 - 保存 mp4 图、WinPython、Anaconda 时

我有下面的代码,当我运行它时,出现下一个错误“ FileNotFoundError:[WinError 2]系统找不到指定的文件”。

我已经添加了日志文件片段。奇怪的是,这段代码昨天在 Anaconda 上运行得非常完美。但是,当尝试在另一台计算机(例如使用 WinPython 的计算机)上运行它时,会弹出错误。(当然,我已经为新机器相应调整了路径)。最糟糕的是,现在它甚至在“原始”机器上也无法工作,而代码是在“原始”机器上开发的并且运行得很好(无需更改任何内容,只需重新启动 PC)。

也许有人遇到同样的问题并找到解决方案。感谢帮助!!

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from scipy import array
from matplotlib import animation
import os



jet = plt.get_cmap('jet')
fig = plt.figure()
ax = fig.gca(projection='3d')

X = np.linspace(70,40,4)
Y = np.linspace(5,2,4)
X,Y=  np.meshgrid(X, Y)

Z = array ([
    [1223.539555, 1428.075086,1714.479425, 2144.053223],
    [1567.26647,1829.056119,2990.416079,2745.320067],
    [2135.163957,2491.534201, 2990.416079,3738.761638],
    [3257.280827, 3800.655101, 4561.372117, 5702.458776],
    ])

surf = ax.plot_surface(X, Y, Z, rstride = 1, cstride = 1, cmap =jet,linewidth = …
Run Code Online (Sandbox Code Playgroud)

python matplotlib file-not-found

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

如何配置Visual Studio的测试应用程序

在我的电脑上,单元测试执行无效.
在同事的PC上,它正在工作(他有一个不同版本的Visual Studio 2017 Professional).
所以我在启动测试时问他输出窗口的结果("调试"标签页),我已经看到他的第一个日志行和我的第一个日志行之间有很大的不同:

我的第一个日志行(部分):

'testhost.x86.exe' (CLR v4.0.30319: DefaultDomain): ...\mscorlib.dll'. ...
Run Code Online (Sandbox Code Playgroud)

他的第一个记录线:

'vstest.executionengine.x86.exe' (CLR v4.0.30319: DefaultDomain): ...\mscorlib.dll'. ...
Run Code Online (Sandbox Code Playgroud)

因此,他的配置似乎使用该程序vstest.executionengine.x86.exe启动单元测试,而我的配置导致程序testhost.x86.exe被使用.

我的PC上有两个程序(UNIX模拟器find结果):

DominiqueDS@DOMINIQUEDS:/C$ find ./ -name "testhost.x86.exe" 2>/dev/null
...
./Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/Extensions/TestPlatform/testhost.x86.exe

DominiqueDS@DOMINIQUEDS:/C$ find ./ -name "vstest.executionengine.x86.exe" 2>/dev/null
./Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TestWindow/vstest.executionengine.x86.exe
...
Run Code Online (Sandbox Code Playgroud)

如何修改Visual Studio环境的配置以便vstest.executionengine.x86.exe用于启动单元测试?

unit-testing visual-studio visual-studio-2017

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

ValueError:未知层:加载keras模型时的名称

我已经训练了一个 CNN 并相应地保存了它:

model = Sequential()
model.add(Flatten(input_shape=train_data.shape[1:]))
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))

model.compile(optimizer='rmsprop',
              loss='binary_crossentropy', metrics=['accuracy'])

model.fit(train_data, train_labels,
          epochs=epochs,
          batch_size=batch_size,
          validation_data=(validation_data, validation_labels))
model.save('full_model.h5')
Run Code Online (Sandbox Code Playgroud)

我现在尝试使用以下命令在另一个 python 脚本中加载模型:

model = tf.keras.models.load_model('full_model.h5')
Run Code Online (Sandbox Code Playgroud)

并收到以下错误:

    Traceback (most recent call last):
  File "/media/spt/Data/tensorflow_server/get_model.py", line 12, in <module>
    model = tf.keras.models.load_model('full_model.h5')
  File "/home/spt/.conda/envs/dev_env/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 229, in load_model
    model = model_from_config(model_config, custom_objects=custom_objects)
  File "/home/spt/.conda/envs/dev_env/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 306, in model_from_config
    return deserialize(config, custom_objects=custom_objects)
  File "/home/spt/.conda/envs/dev_env/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py", line 64, in deserialize
    printable_module_name='layer')
  File "/home/spt/.conda/envs/dev_env/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 173, in deserialize_keras_object
    list(custom_objects.items())))
  File "/home/spt/.conda/envs/dev_env/lib/python3.6/site-packages/tensorflow/python/keras/engine/sequential.py", line 286, …
Run Code Online (Sandbox Code Playgroud)

python keras tensorflow valueerror

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

GC 终结器线程崩溃,“DestroyScout”有什么问题?

我面临着一个 .Net 服务器应用程序,该应用程序几乎每周都会因“GC Finalizer Thread”中的问题而崩溃,更准确地说是在“mscorlib.dll ...~DestroyScout()”的第 798 行,根据视觉工作室。

Visual Studio 还尝试打开文件“DynamicILGenerator.gs”。我没有这个文件,但我找到了该文件的一个版本,其中第 798 行确实位于析构函数或DestroyScout(无论这可能意味着什么)内部。

我的 Visual Studio 环境中有以下信息:

主题:

Not Flagged >   5892    0   Worker Thread   GC Finalizer Thread mscorlib.dll!System.Reflection.Emit.DynamicResolver.DestroyScout.~DestroyScout
Run Code Online (Sandbox Code Playgroud)

调用堆栈:

    [Managed to Native Transition]  
>   mscorlib.dll!System.Reflection.Emit.DynamicResolver.DestroyScout.~DestroyScout() Line 798   C#
[Native to Managed Transition]  
kernel32.dll!@BaseThreadInitThunk@12()  Unknown
ntdll.dll!__RtlUserThreadStart()    Unknown
ntdll.dll!__RtlUserThreadStart@8()  Unknown
Run Code Online (Sandbox Code Playgroud)

当地人(无法确定该$exception对象是否正确):

+       $exception  {"Exception of type 'System.ExecutionEngineException' was thrown."} System.ExecutionEngineException
    this    Cannot obtain value of the local variable or argument because it is not available at this …
Run Code Online (Sandbox Code Playgroud)

c# multithreading garbage-collection dump windows-server-2016

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

Docker SQL-Server登录问题:AuthenticationException:远程证书被提供的RemoteCertificateValidationCallback拒绝

我正在开发一个与 Docker 相关的应用程序,该应用程序是用 C# 编写的,基于实体框架。

Docker 容器之一是 ms-sql-server,用于数据库访问。
为了访问 SQL 服务器,connectionString创建以下内容:

Server=ms-sql-server;Initial Catalog=Ownobjects;User ID=SA;Password=some_password
Run Code Online (Sandbox Code Playgroud)

执行以下源代码时:

public void InitialiseDatabase(IApplicationBuilder app)
{
  using (var context = app.ApplicationServices.GetRequiredService<ApplicationDbContext>())
  {
    context.Database.EnsureCreated();
    ...
Run Code Online (Sandbox Code Playgroud)

...我得到以下信息Exception

Microsoft.Data.SqlClient.SqlException: 'A connection was successfully established with the server,
  but then an error occurred during the pre-login handshake.
  (provider: TCP Provider, error: 35 - An internal exception was caught)'  

Inner Exception  
AuthenticationException: The remote certificate was rejected
  by the provided RemoteCertificateValidationCallback.
Run Code Online (Sandbox Code Playgroud)

根据这个类似的 StackOverflow 帖子,有两件事可能不匹配:连接字符串中的实例名称和实例中的预期名称。

  1. 这是真的?在这种情况下,我在哪里或如何找到这两个名字? …

c# sql-server entity-framework connection-string docker

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

堆扩展命令失败:无法初始化扩展

在尝试使用!heapWindbg中的扩展来调查转储时,我收到以下错误:

0:000> !heap -s -v -a
SEGMENT HEAP ERROR: failed to initialize the extention
Run Code Online (Sandbox Code Playgroud)

每次使用!heap扩展时都会发生这种情况.
谷歌对此事并不是很有帮助.有没有人知道如何解决这个问题?

windbg dump

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