小编Cha*_*age的帖子

Angular2 RC6:'<component>不是已知元素'

尝试运行我的Angular 2 RC6应用程序时,在浏览器控制台中出现以下错误:

> Error: Template parse errors: 'header-area' is not a known element:
> 1. If 'header-area' is an Angular component, then verify that it is part of this module.
> 2. If 'header-area' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component
> to suppress this message.("

    <div class="page-container">
        [ERROR->]<header-area></header-area>
        <div class="container-fluid">

> "): PlannerComponent@1:2
Run Code Online (Sandbox Code Playgroud)

我不明白为什么找不到该组件.我的PlannerModule看起来像这样:

@NgModule({
  declarations: [
    PlannerComponent,
    HeaderAreaComponent,
    NavbarAreaComponent,
    EreignisbarAreaComponent,
    GraphAreaComponent,
    nvD3
    ],
  imports: [
    RouterModule,
    CommonModule,
    ModalModule
    ],
  bootstrap: [PlannerComponent], …
Run Code Online (Sandbox Code Playgroud)

angular

115
推荐指数
7
解决办法
14万
查看次数

如何通过嵌入式URL将参数传递给PowerBI Embedded

我有一个IFrame,它显示了具有世界地图的PowerBI嵌入式报告.我是否可以通过嵌入式URl将参数传递给PowerBI Embedded,以根据特定国家/地区过滤我的报告.

谢谢

azure powerbi powerbi-embedded

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

在python中交谈时将语音转换为文本

我制作了一个程序,可以让我说出来并将其转换为文本。我停止讲话后,它会转换我的声音。我想做的是在讲话时将语音转换为文本。

https://www.youtube.com/watch?v=96AO6L9qp2U&t=2s&ab_channel=StormHack的播放时间为2:31。

注意Tony显示器的右上角。它可以在通话时将他的声音转换为文本。我想做同样的事情。能做到吗

这是我的整个程序:

import speech_recognition as sr 
import pyaudio


r = sr.Recognizer()
with sr.Microphone() as source:
    print("Listening...")
    audio = r.listen(source)
    try:
        text = r.recognize_google(audio)
        print("You said : {}".format(text))
    except:
        print("Sorry could not recognize what you said")
Run Code Online (Sandbox Code Playgroud)

解决方案,提示,提示或其他任何东西,将不胜感激,在此先感谢您。

python text-to-speech voice-recording voice-recognition python-3.x

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

在 PyInstaller 中使用 OpenCV

尝试使用 PyInstaller 创建 Python 程序的二进制可执行文件时出现错误。但是,config.py 文件似乎存在一些问题。如果我尝试导入 cv2,则会收到以下错误消息:

Traceback (most recent call last):
File "exec_test.py", line 1, in <module>
File "/Users/me/path/to/.env/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages/cv2/__init__.py", line 89, in <module>
File "site-packages/cv2/__init__.py", line 58, in bootstrap
File "site-packages/cv2/__init__.py", line 56, in load_first_config
ImportError: OpenCV loader: missing configuration file: ['config.py']. 
Check OpenCV installation.
[10914] Failed to execute script exec_test
Run Code Online (Sandbox Code Playgroud)

我正在使用以下代码:

import cv2

if __name__ == '__main__':
    print("Hello, world!")
Run Code Online (Sandbox Code Playgroud)

当我用 Python 运行它时,这完全没问题。

要编译可执行文件,我正在运行:

pyinstaller --onefile local-processing/exec_test.py
Run Code Online (Sandbox Code Playgroud)

当 PyInstaller 运行时,它具有以下输出:

50 …
Run Code Online (Sandbox Code Playgroud)

python opencv pyinstaller python-3.x

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

如果抛出异常,.Net Web API 有时根本不返回任何响应

首先介绍一下背景。
我在 Visual Studio 2017 社区中使用 .Net Framework 4.6.1、Microsoft.AspNet.WebApi 5.2.4。

我的 ApiController 的实现端点会抛出预期的异常,例如,如果未满足某些要求。我添加了全局 ExceptionFilterAttribute 和 ExceptionHandler 来处理这些异常并返回正确的响应。异常是继承自 System.Exception 的类型。
这只是偶尔按预期工作。每隔第二个或第三个或有时第五个(没有真正的模式)请求,api 服务器根本不返回任何响应,例如邮递员说:“无法得到任何响应”。
为了测试这一点,我使用了具有相同输入的相同端点。

为了更好地了解该问题,我做了以下一些事情:
我向 Global.asax 添加了异常日志记录(以捕获第一次机会异常)
我订阅了 Global.asax Application_Error 事件
我查看了 IIS 日志

这些都没有让我更接近这个问题。像预期的那样捕获并记录了 Global.asax 异常,但没有其他错误或异常可以为我的问题提供更多信息。

这是我的代码:
我简化了 ApiController 的功能并删除了业务逻辑。

[Route("test")]
[HttpGet]
public IHttpActionResult GetTest()
{
    throw new ObjectAlreadyExistsException("test");
    return ResponseFactory.CreateOkResponse(null);
}

public class ExceptionFilter : ExceptionFilterAttribute
{
    public override void OnException(HttpActionExecutedContext context)
    {
        if (context.Exception is ObjectAlreadyExistsException)
        {
            context.Response = ResponseFactory.CreateErrorResponseMessage(context.Exception.Message, new Error("OBJECT_ALREADY_EXISTS_ERROR", context.Exception.Message));
        }
        else if (context.Exception is …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net-web-api

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

桌面悬停(引导程序)不适用于反应

我已经用 NPM 安装了 popper 和 jquery。

并在 App.js 中导入:

import '../node_modules/jquery/dist/jquery.min.js'
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
import '../node_modules/bootstrap/dist/js/bootstrap.min.js';
Run Code Online (Sandbox Code Playgroud)

css 部分似乎工作正常,但我没有看到任何 jquery(bootstrap.js) 正在运行。当我使用 table 时,table-striped 和 table-hover 不起作用。这是我正在测试的代码,来自 Traversy Media(我粘贴在 App.js 的渲染中)。我已经尝试过 class 和 className

<div className="container">
      <table className="table table-striped table-bordered table-hover table-condensed">
        <tr>
          <th>Firstname</th>
          <th>Lastname</th>
          <th>Age</th>
        </tr>
        <tr class="danger">
          <td>Jill</td>
          <td>Smith</td>
          <td>50</td>
        </tr>
        <tr>
          <td>Eve</td>
          <td>Jackson</td>
          <td>24</td>
        </tr>
        <tr class="success">
          <td>John</td>
          <td>Doe</td>
          <td>34</td>
        </tr>
        <tr>
          <td>Stephanie</td>
          <td>Landon</td>
          <td>47</td>
        </tr>
        <tr>
          <td>Mike</td>
          <td>Johnson</td>
          <td>19</td>
        </tr>
      </table>
</div>
Run Code Online (Sandbox Code Playgroud)

谢谢

javascript reactjs bootstrap-4

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

如何手动设置 HttpContext.User.Identity.IsAuthenticated 的值

我正在创建一个 Asp.NET MVC 5 应用程序。对于这个项目,我正在尝试实现自定义身份验证机制(我不想使用表单身份验证/OWIN 等外部提供程序)

我创建了一个自定义授权属性,如下所示:

[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class myAuthorize : AuthorizeAttribute
{
    protected override bool AuthorizeCore(HttpContextBase httpContext)
    {            
        if (!HttpContext.Current.Request.IsAuthenticated)
        {
            httpContext.Response.Redirect("~/Account/Login");
        }                            

        return base.AuthorizeCore(httpContext);
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的登录操作中,我试图更改的值

HttpContext.User.Identity.IsAuthenticated
Run Code Online (Sandbox Code Playgroud)

但它是只读的,我无法更改该值。我可以手动更改它的值还是我犯了一个逻辑错误。

c# model-view-controller

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

加载模型时如何使用 min max scaler 拟合测试数据?

我正在做自动编码器模型。我已经保存了模型,在此之前我使用 min max scaler 缩放了数据。

X_train = df.values
scaler = MinMaxScaler()
X_train_scaled = scaler.fit_transform(X_train)
Run Code Online (Sandbox Code Playgroud)

完成此操作后,我安装了模型并将其保存为“h5”文件。现在当我提供测试数据时,在自然加载保存的模型后,它也应该进行缩放。

所以当我加载模型并使用

X_test_scaled  = scaler.transform(X_test)
Run Code Online (Sandbox Code Playgroud)

它给出了错误

NotFittedError: This MinMaxScaler instance is not fitted yet. Call 'fit' with appropriate arguments before using this method.
Run Code Online (Sandbox Code Playgroud)

所以我给出了X_test_scaled = scaler.fit_transform(X_test) (我有一种预感,它是愚蠢的)确实给出了一个结果(在加载保存的模型和测试之后),当我训练它并一起测试时它是不同的。为了我的目的,我现在已经保存了大约 4000 个模型(所以我无法训练并再次保存它,因为它花费了很多时间,所以我想要一条出路)。

有没有一种方法可以通过按照我训练的方式对其进行转换来缩放测试数据(可能是保存缩放值,我不知道)。或者可以对模型进行去缩放,以便我可以在非缩放数据上测试模型.

如果我没有强调或过分强调任何一点,请在评论中告诉我!

python scaling test-data machine-learning normalization

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

替换 Pandas 中的逗号和点

我有一个包含 3.4500,00 欧元等数据的列。现在我想将此与具有浮点数(如 4000.00)的另一列进行比较。我如何取这个字符串,删除欧元并用十进制替换逗号,然后转换为浮点数进行比较。

python decimal comma euro pandas

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

如何使用C#在Unity 3D中的随机时间(相同位置)生成敌人?

我每个人都反复产生敌人1.75f。但是我不知道如何使用随机函数。我的原型游戏就像Chrome浏览器中的游戏,当找不到页面时就会显示。

感谢你们对我的帮助。

这是我的代码:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class EnemyGeneratorController : MonoBehaviour
    {
        public GameObject enemyPrefeb;
        public float generatorTimer = 1.75f;

        void Start () 
        {

    }

    void Update ()
    {

    }

    void CreateEnemy()
    {
        Instantiate (enemyPrefeb, transform.position, Quaternion.identity);
    }

    public void StartGenerator()
    {
        InvokeRepeating ("CreateEnemy", 0f, generatorTimer);
    }

    public void CancelGenerator(bool clean = false)
    {
        CancelInvoke ("CreateEnemy");
        if (clean)
        {
            Object[] allEnemies = GameObject.FindGameObjectsWithTag ("Enemy");
            foreach (GameObject enemy in allEnemies)
            {
                Destroy(enemy);
            }
        }   
    }
}
Run Code Online (Sandbox Code Playgroud)

c# game-development game-engine unity-game-engine

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