小编rob*_*más的帖子

从 keras 模型中删除警告

我在构建模型时收到警告——一开始我不认为这是真的;也许事情已经改变了:

模型:

# Initialise Sequential model
regressor = Sequential()

# units is the output dimensionality
# return sequences will return the sequence
# which will be required to the next LSTM 

# as a great big rule-o-thumb, layers should be less than 10, and perhaps 1 per endog plus 1 for all exog
# also see: https://stats.stackexchange.com/questions/181/how-to-choose-the-number-of-hidden-layers-and-nodes-in-a-feedforward-neural-netw/1097#1097

alphaNh = len(columns) if len(columns) < 10 else 10 # 2-10, with 2 or 5 being common
sample_frames = n
nh = int(sample_frames/alphaNh*dim) …
Run Code Online (Sandbox Code Playgroud)

python keras tensorflow

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

是否可以告诉ruby在某些情况下接受左手变量?

我正在寻找的行为是这样我可以定义方法来获得这样的结果:

> 2i
=> Complex(0,+2i)
> 2²
=> 4
Run Code Online (Sandbox Code Playgroud)

ruby

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

是否有更有效的方法来打开字符串数组的每个元素?

我有一个数组var mya = ["someval1", "someotherval1", "someval2", "someval3"];,我有一个函数接收一个属性设置为其中一个名称的对象.

迭代数组是有意义的,并检查每个数组是否可以在数组中找到它,就像在for语句中一样.但switch在这种情况下,似乎更有效的方法会使用语句,因为数组是静态的,当我找到属性时的任务取决于找到的属性.

如何使用开关阵列执行此操作?像这样的伪代码:

switch(mya.forEach) { 
    case "someval1": 
        alert("someval1"); 
        break; 
    ... 
    default: 
        alert("default"); 
        break; 
}
Run Code Online (Sandbox Code Playgroud)

但这只召唤一次.

给出的答案都是我已经拥有的代码 - 我猜有没有更清晰的foreach配方switch.

javascript arrays switch-statement

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

为什么“gulp watch”没有更新?

这里可能有几个小的样式问题,但大多数情况下是有效的。但是,它似乎并没有监视styles/*.scss该文件夹中文件或新 SCSS 的更改。与 Javascript 相同:scripts/*.js不在手表上更新。

也可以在不破坏源映射的情况下结合 SCSS 和 CSS,但这并不重要。现在,只要让实时更新工作就好了。

const gulp = require('gulp')
const plumber = require('gulp-plumber')
const rename = require('gulp-rename')
const autoprefixer = require('gulp-autoprefixer')
const babel = require('gulp-babel')
const concat = require('gulp-concat')
const sass = require('gulp-sass')
const browserSync = require('browser-sync')
const clean = require('gulp-clean')
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
const minifycss = require('gulp-minify-css');

const gulpfn = require('gulp-fn')
const fs = require('fs');

const util = require('gulp-util');
let config = { production: !!util.env.production } …
Run Code Online (Sandbox Code Playgroud)

gulp gulp-sass gulp-watch gulp-sourcemaps

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

不能使用变异成员...因为追加?

我很困惑为什么我得到这个错误(swift 4.2.1).

// next, select only entries in range
let filteredDataOpt: [TimeSeriesEntry?] = filteredApps
    .map { data in
        let isInDate = dates.contains { date in
            guard let d = date else {
                return false
            }
            return Calendar.current.isDate(d, equalTo: data.date, toGranularity: Calendar.Component.day)
        }
        return isInDate ? timeSeriesDataFromAppData(data) : nil
    }.append(contentsOf: locationsData.map { data in
        let isInDate = dates.contains { date in
            guard let d = date else {
                return false
            }
            return Calendar.current.isDate(d, equalTo: data.date, toGranularity: Calendar.Component.day)
        }
        return isInDate ? …
Run Code Online (Sandbox Code Playgroud)

swift

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

长度必须匹配才能比较(熊猫根据两个标准进行选择)

我为每个用户生成值,如下所示:

loDf = locDfs[user] # locDfs is a copy of locationDf elsewhere in the code... sorry for all the variable names.
loDf.reset_index(inplace=True)
loDf = pd.crosstab([loDf.date, loDf.uid], loDf.location_id)
loDf.reset_index(inplace=True)

loDf.set_index('date', inplace=True)
loDf.drop('uid', axis=1, inplace=True)

# join the location crosstab columns with the app crosstab columns per user
userLocAppDfs[user] = userLocAppDfs[user].join(loDf, how='outer')
# convert from just "1" at each location change event followed by zeros, to "1" continuing until next location change
userLocAppDfs[user] = userLocAppDfs[user].resample('15T').agg('max')
userLocAppDfs[user]['uid'].fillna(user, inplace=True)
Run Code Online (Sandbox Code Playgroud)

这获取位置数据并将 location_id 转换为列,并将其与时间序列中的其他数据组合。

这本质上包括重塑数据。然后我需要标准化,为此,我需要查看每个列的值:

for …
Run Code Online (Sandbox Code Playgroud)

python pandas

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

RXJS 6处理http Observable的方式是什么?

我注意到当我在新项目中使用它时,我的代码不起作用:

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

import { TypeAndCountURL } from '@app/constants';
import { HttpErrorService } from '@app/services/http-error.service';
import { TypeAndCountResponseBody, TypeAndCountRequestBody } from '@app/models/type-and-count/bodies.interface';

@Injectable({
  providedIn: 'root'
})
export class ApiService {
  constructor (private http: HttpClient, private httpErrorService: HttpErrorService) {}

  postTypeAndCountRequest(typeAndCountRequestBody: TypeAndCountRequestBody): Observable<TypeAndCountResponseBody> {
    return this.http.post<TypeAndCountResponseBody>(TypeAndCountURL, typeAndCountRequestBody).pipe(
      catchError(this.httpErrorService.handleError<TypeAndCountResponseBody>('postTypeAndCountRequest'))
    );

  }
}
Run Code Online (Sandbox Code Playgroud)

具体来说,我正在 Cannot find name 'catchError'. Did you mean 'RTCError'?ts(2552)

仔细阅读,我可以通过单独导入来解决问题(从rxjs / operators .. whihc很好,但是)..而且整个结构都是rxjs 5的兼容模式...什么是RXJS …

javascript rxjs typescript angular

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

openapi-generator 如何在我的解决方案的 MS 测试项目中生成 c-sharp .NET core 3.1 兼容测试?

我有一个 .net-core 3.1 解决方案,其简单端点仅接受帖子。我想使用 openAPI-generator 生成 SDK(因为Visual Studio for mac中不提供 New REST Client SDK 选项)。

我第一次这样做时,我使用以下命令:

openapi-generator generate -i ../swagger.v0.0.21.json -g csharp -o ./generator
Run Code Online (Sandbox Code Playgroud)

这生成了一个 .net 框架解决方案,因此我必须对其进行一些修改并安装一些 nuget 测试库才能使其运行。毕竟我的连接被拒绝了——我希望这只是因为它是为错误的框架构建的。

我注意到还有另一个生成目标csharp-netcore。但我不确定如何使用它。我的命令应该是什么样的?我刚在想:

openapi-generator generate -i ../swagger.v0.0.21.json -g csharp-netcore -targetFramework netcoreapp3.1 -o ./generator
Run Code Online (Sandbox Code Playgroud)

但这会产生:

[error] Found unexpected parameters: [netcoreapp3.1]
Run Code Online (Sandbox Code Playgroud)

(明确地说,我有一个解决方案结构:

  • 作业_1/
    • 作业_1_测试/

我正是想进行测试。但我的来源直接来自Assignment_1 目录。

c# swagger .net-core openapi openapi-generator

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

git push 到新的上游分支

我有一个存储库尚未与我想要将其推送到的存储库关联。审核通过后,我们准备提交工作中征求意见。

首先,我添加了我想将其推送到的上游存储库:

git remote add upstream git@ssh.dev.azure.com:v3/place/projectgroup/repo

这是第一个也是唯一一个添加的上游,和之前一样它只存在于我的 Mac 上。然后我尝试添加上游:

$ git branch --set-upstream-to origin/candidate/1.0
error: the requested upstream branch 'origin/candidate/1.0' does not exist
hint: 
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint: 
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to …
Run Code Online (Sandbox Code Playgroud)

git

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

如何从 Int 的 sqrt 获得最近的 Int?

我需要等于或低于 n 的 sqrt 的最大整数。

我得到无法在不可变值上使用变异成员:'sqrt'返回不可变值

func isPrime (n:Int) ->  Bool {
    if n < 2 { return false }

    generatePrimes(to: sqrt(Double(n)).round(.towardZero))
Run Code Online (Sandbox Code Playgroud)

同样的问题 .squareRoot

我如何生成 to:Int 在这里?

swift

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