小编Aks*_*kar的帖子

将numpy数组类型和值从Float64转换为Float32

我试图将类型从Float64转换为Float32的阈值数组(隔离森林的pickle文件从scikit学习)

for i in range(len(tree.tree_.threshold)):
    tree.tree_.threshold[i] = tree.tree_.threshold[i].astype(np.float32)
Run Code Online (Sandbox Code Playgroud)

然后打印它

for value in tree.tree_.threshold[:5]:
    print(type(value))
    print(value)
Run Code Online (Sandbox Code Playgroud)

我得到的输出是:

<class 'numpy.float64'>
526226.0
<class 'numpy.float64'>
91.9514312744
<class 'numpy.float64'>
3.60330319405
<class 'numpy.float64'>
-2.0
<class 'numpy.float64'>
-2.0
Run Code Online (Sandbox Code Playgroud)

我没有得到正确的转换到Float32.我想将值及其类型转换为Float32,有没有人有解决方法?

python numpy pickle scikit-learn

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

如何通过Terraform执行PowerShell命令

我正在尝试从AMI创建Windows Ec2实例,并在该实例上执行powershell命令:

data "aws_ami" "ec2-worker-initial-encrypted-ami" {
    filter {
        name   = "tag:Name"
        values = ["ec2-worker-initial-encrypted-ami"]
    }  
}

resource "aws_instance" "my-test-instance" {
  ami             = "${data.aws_ami.ec2-worker-initial-encrypted-ami.id}"
  instance_type   = "t2.micro"

  tags {
    Name = "my-test-instance"
  }

  provisioner "local-exec" {
    command = "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule",
    interpreter = ["PowerShell"]
  }

}
Run Code Online (Sandbox Code Playgroud)

而且我面临以下错误:

  • aws_instance.my-test-instance:运行命令'C:\ ProgramData \ Amazon \ EC2-Windows \ Launch \ Scripts \ InitializeInstance.ps1 -Schedule'时出错:退出状态1.输出:术语'C:\ ProgramData \ Amazon \ EC2-Windows \ Launch \ Scripts \ InitializeInstance.ps1'无法识别为cmdlet,函数,脚本文件或可运行程序的名称。检查名称的拼写,或者是否包含路径,请验证路径是否正确,然后重试。在线:1字符:72
  • C:\ ProgramData \ Amazon \ EC2-Windows \ Launch \ Scripts \ …

powershell amazon-ec2 amazon-web-services terraform

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