我刚刚复制并粘贴了datePicker和输入的角度材料代码,但是我收到了datePicker的这个错误.
app.module
import {MaterialModule} from '@angular/material';
@NgModule({
imports: [
...
MaterialModule
]
Run Code Online (Sandbox Code Playgroud)
<md-input-container>
    <input mdInput placeholder="Rechercher" [(ngModel)]="filterHistorique">
</md-input-container>
<md-input-container>
    <input mdInput [mdDatepicker]="picker" placeholder="Choose a date">
    <button mdSuffix [mdDatepickerToggle]="picker"></button>
</md-input-container>
<md-datepicker #picker></md-datepicker>
Run Code Online (Sandbox Code Playgroud)
这是我在浏览器中出现的错误:
无法绑定到'mdDatepicker',因为它不是'input'的已知属性如果'md-datepicker'是Angular组件,则验证它是否是此模块的一部分.2.如果'md-datepicker'是Web组件,则将"CUSTOM_ELEMENTS_SCHEMA"添加到此组件的'@NgModule.schemas'以禁止显示此消息.("[错误 - >]
错误是针对datepicker,当我删除它时,错误消失
我正在学习 Tensorflow (2.0) 的最新版本,并尝试运行一个简单的代码来切片矩阵。使用装饰器 @tf.function 我做了以下类:
class Data:
def __init__(self):
    pass
def back_to_zero(self, input):
    time = tf.slice(input, [0,0], [-1,1])
    new_time = time - time[0][0]
    return new_time
@tf.function
def load_data(self, inputs):
    new_x = self.back_to_zero(inputs)
    print(new_x)
Run Code Online (Sandbox Code Playgroud)
因此,当使用 numpy 矩阵运行代码时,我无法检索数字。
time = np.linspace(0,10,20)
magntiudes = np.random.normal(0,1,size=20)
x = np.vstack([time, magntiudes]).T
d = Data()
d.load_data(x)
Run Code Online (Sandbox Code Playgroud)
输出:
Tensor("sub:0", shape=(20, 1), dtype=float64)
Run Code Online (Sandbox Code Playgroud)
我需要以 numpy 格式获取此张量,但 TF 2.0 没有使用 run() 或 eval() 方法的 tf.Session 类。
感谢您为我提供的任何帮助!
服务器正在发送视频帧.我想用它们来做流媒体.我想知道如何组装帧以创建流式视频.到目前为止,我可以将帧显示为图片.下面是我的角度代码
分量角
 getVideo() {
    interval(250).switchMap(() => this.appService.getPictures())
      .subscribe(data => {
        const file = new Blob([data], {type:'image/png'});
        this.url = this.sanitizer.bypassSecurityTrustResourceUrl(URL.createObjectURL(file));
      })
  }
Run Code Online (Sandbox Code Playgroud)
模板html
<img div="test" [src]="url" width="400px" height="300px"/>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用相机的帧速率更改图片.但我的图片没有更新,由于http请求数量很多,它冻结了我的浏览器.
我想要实现的是缓冲帧以便使用video标记而不是img标记,就像我使用设置为服务器的video标记连接到服务器的实时流式传输一样.srcurl
出于某种原因,互联网缺乏关于如何在Angular 4中使用的示例(它使用TypeScript,它不允许您跳过包括选项属性,如它转换成的JavaScript).
我正试图点击我的团队的RESTful API,这需要一个带有GET请求的身份验证令牌,例如:
return this.http.get(this.BASE_URL + '/api/posts/unseen/all', {
            headers : {
                "Authorization": 'Token token="' + TokenService.getToken() + '"'
            }   
        })
Run Code Online (Sandbox Code Playgroud)
TokenService我写的业务服务类在哪里返回令牌以便在应用程序中使用.打字后,我得到了这个错误:
我出现的服务文件中的依赖项是:
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions, Response } from '@angular/http';
import { Post } from '../models/post'; // business class 
import 'rxjs/';
import { User } from '../models/user'; // business class
import { HttpService } from './http.service'; // service for connecting us to the base location of the endpoints. provides BASE_URL to …Run Code Online (Sandbox Code Playgroud) 使用 observable,我想过滤并显示一个列表。输入event只有当用户开始输入被触发。因此,列表不会首先显示。this.filterLocation$在inputEvent开始被触发之前,如何为 observable 分配默认值?
模板
<ng-template ngFor let-location [ngForOf]="filterLocation$ | async">
        <a mat-list-item href="#">{{location}}</a>
      </ng-template>
Run Code Online (Sandbox Code Playgroud)
成分
ngAfterViewInit() {
const searchBox = document.querySelector('#search-input');
this.filterLocation$ = fromEvent(searchBox, 'input')
  .pipe(
    map((e: any) => {
      const value = e.target.value;
        return value ? this.locations
          .filter(l => l.toLowerCase().includes(value.toLowerCase()))
          : this.locations;
      }),
      startWith(this.locations)
  )
 }
}
Run Code Online (Sandbox Code Playgroud)
使用startWith使列表最初显示。但是抛出以下错误:
错误:ExpressionChangedAfterItHasBeenCheckedError:检查后表达式已更改。以前的值:'ngForOf: null'。当前值:'ngForOf: name1,name2'。
出于学习目的,我正在使用Tensorflow.js,并且在尝试将该fit方法与批处理数据集(10 x 10)一起使用时遇到错误,以了解批处理培训的过程.
我有一些想要分类的图像600x600x3(2个输出,1或0)
这是我的训练循环:
  const batches = await loadDataset()
  for (let i = 0; i < batches.length; i++) {
    const batch = batches[i]
    const xs = batch.xs.reshape([batch.size, 600, 600, 3])
    const ys = tf.oneHot(batch.ys, 2)
    console.log({
      xs: xs.shape,
      ys: ys.shape,
    })
    // { xs: [ 10, 600, 600, 3 ], ys: [ 10, 2 ] }
    const history = await model.fit(
      xs, ys,
      {
        batchSize: batch.size,
        epochs: 1
      }) // <----- The code throws here
    const loss …Run Code Online (Sandbox Code Playgroud) javascript classification machine-learning tensorflow tensorflow.js
我试图运行此代码,但每次收到此错误消息时。首先,我在npm全球安装。然后我将其安装在我的应用程序中,但仍然出现相同的错误。
Uncaught TypeError:无法读取对象上未定义的属性“ on”。(H:\ electric \ main.js:12:4)在对象处。(H:\ electric \ main.js:63:3)在Module._compile(module.js:571:32)在Object.Module._extensions..js(module.js:580:10)在Module.load(在try.ModuleLoad(module.js:447:12)在function.Module._load(module.js:439:3)在module.require(module.js:498:17)在require(在internal / module.js:20:19),位于文件:/// H:/electric/views/login.html:2:3
const electron = require('electron');
const {Menu} = require('electron');
const {app} = require('electron');
const {BrowserWindow} = require('electron');
const conn = require('mysql');
const path = require('path');
const url = require('url');
// const app = electron.app;
// const BrowserWindow = electron.BrowserWindow;
var mainWindow = null;
app.on('ready', function () {
    mainWindow = new BrowserWindow({ width: 1024, height: 768, backgroundcolor: '#2e2c29' });
    mainWindow.loadURL(url.format({
        pathname: 'popupcheck.html',
        protocol: 'file:',
        slashes: true
    }));enter …Run Code Online (Sandbox Code Playgroud) 使用MutationObserver我想检测由于组件中的媒体查询而导致的 dom 元素更改。
但是 MutationObserver 在样式改变时无法触发事件。
detectDivChanges() {
    const div = document.querySelector('.mydiv');
    const config = { attributes: true, childList: true, subtree: true };
    const observer = new MutationObserver((mutation) => {
      console.log("div style changed");
    })
    observer.observe(div, config);
  }
}
Run Code Online (Sandbox Code Playgroud)
<div class="mydiv">test</div>
Run Code Online (Sandbox Code Playgroud)
.mydiv {
  height: 40px;
  width: 50px;
  background-color: red;
}
@media screen and (min-width : 500px) {
  .mydiv {
    background-color: blue;
  }
}
Run Code Online (Sandbox Code Playgroud)
这是代码的实时版本
我想通过它们的字符串键值 ( description)之一对 Javascript 对象进行聚类。我已经尝试了多种解决方案,并希望获得有关如何解决问题的一些指导。
我想要什么:假设我有一个对象数据库。可能有很多(可能有数千个,也可能有数万个)。我需要能够:
categoryId每一个分配一些(代表它们所属的集群)。我还没有尝试解决问题 #2,但这是我尝试解决问题 #1 的方法。
具有 Levenshtein 距离(单链接)的层次聚类- 这里的问题是性能,结果令人满意(我使用了hierarchical-clustering来自 的库npm)但在 150 左右我将不得不等待大约一分钟。不会为数千人工作。
TF-IDF,矢量化 + k-means - 性能很棒。它将轻松通过 5000 个对象。但结果肯定是关闭的(可能是我的实现中的一个错误)。我使用(natural库 fromnpm来计算 TF-IDF 和node-kmeans)。
Bag-of-Words + k-means - 我现在正在尝试实现这个,还没有任何运气。
对于#2,我想过使用朴素贝叶斯(但我还没有尝试过)。
有什么建议?如果对象只是聚集在一起就好了。如果我可以提取组聚类所依据的标签(如从 TF-IDF 中提取),那就更好了。
一般来说,我对Tensorflowjs和Tensorflow还是很陌生。我有一些数据,容量使用率超出100%,因此数字介于0和100之间,并且每天有5个小时记录这些容量。所以我有一个5天的矩阵,其中100%中包含5个百分比。
我有以下模型:
const model = tf.sequential();
model.add(tf.layers.dense({units: 1, inputShape: [5, 5] }));
model.compile({ loss: 'binaryCrossentropy', optimizer: 'sgd' });
// Input data
// Array of days, and their capacity used out of 
// 100% for 5 hour period
const xs = tf.tensor([
  [11, 23, 34, 45, 96],
  [12, 23, 43, 56, 23],
  [12, 23, 56, 67, 56],
  [13, 34, 56, 45, 67],
  [12, 23, 54, 56, 78]
]);
// Labels
const ys = tf.tensor([[1], [2], [3], [4], [5]]);
// Train the …Run Code Online (Sandbox Code Playgroud) angular ×5
javascript ×5
tensorflow ×3
algorithm ×1
angular-http ×1
electron ×1
html5-video ×1
k-means ×1
nlp ×1
python ×1