小编Thi*_*den的帖子

仅使用1-5%Tensorflow-gpu和Keras的GPU

我刚刚为gpu安装了tensorflow,并为我的CNN使用了keras。在训练期间,我的GPU仅使用了5%,但是在训练期间使用了6GB的vram中的5个。有时会出现故障,在控制台上打印0.000000e + 00,gpu降到100%,但几秒钟后,训练速度又降低到5%。我的GPU是Zotac gtx 1060 mini,我正在使用Ryzen 5 1600x。

Epoch 1/25
 121/3860 [..............................] - ETA: 31:42 - loss: 3.0575 - acc: 0.0877 - val_loss: 0.0000e+00 - val_acc: 0.0000e+00Epoch 2/25
 121/3860 [..............................] - ETA: 29:48 - loss: 3.0005 - acc: 0.0994 - val_loss: 0.0000e+00 - val_acc: 0.0000e+00Epoch 3/25
  36/3860 [..............................] - ETA: 24:47 - loss: 2.9863 - acc: 0.1024
Run Code Online (Sandbox Code Playgroud)

python spyder deep-learning keras tensorflow-gpu

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

如何从UIView中删除CAShapeLayer和CABasicAnimation?

这是我的代码:

@objc func drawForm() {
    i = Int(arc4random_uniform(UInt32(formNames.count)))
    var drawPath = actualFormNamesFromFormClass[i]
    shapeLayer.fillColor = UIColor.clear.cgColor
    shapeLayer.strokeColor = UIColor.black.cgColor
    shapeLayer.lineWidth = 6
    shapeLayer.frame = CGRect(x: -115, y: 280, width: 350, height: 350)

    var paths: [UIBezierPath] = drawPath()
    let shapeBounds = shapeLayer.bounds
    let mirror = CGAffineTransform(scaleX: 1,
                                   y: -1)
    let translate = CGAffineTransform(translationX: 0,
                                      y: shapeBounds.size.height)
    let concatenated = mirror.concatenating(translate)

    for path in paths {
        path.apply(concatenated)
    }

    guard let path = paths.first else {
        return
    }

    paths.dropFirst()
        .forEach {
            path.append($0)
    }

    shapeLayer.transform …
Run Code Online (Sandbox Code Playgroud)

cabasicanimation cashapelayer cgpath swift swift-playground

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

"CMSampleBuffer"类型的值没有成员"imageBuffer"

我目前正在开发一个在Swift中使用实时摄像头视图的项目.我使用了一些我在GitHub上找到的代码给我实时摄像机视图,它在运行Mojave的MacBook Pro上运行良好.我将所有文件存储在外部硬盘上,所以我去了iMac并开始在那里开展项目.我想我有两个不同版本的Xcode 10 beta,这可能是问题的一部分?基本上这条线在我的MacBook上工作正常,但在iMac上没有,btw正在运行macOS high Sierra 15:

guard let pixelBuffer : CVPixelBuffer = sampleBuffer.imageBuffer else { return }
Run Code Online (Sandbox Code Playgroud)

它给了我以下错误:

Value of type 'CMSampleBuffer' has no member 'imageBuffer'
Run Code Online (Sandbox Code Playgroud)

但是当我在我的macbook上打开完全相同的项目时,这没有任何问题.这可能是一个Xcode版本的东西,还是因为我运行两个不同的macOS版本?

camera ios cmsamplebuffer swift xcode10

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

如何为CGpath数组的绘制设置动画?

我正在尝试制作一个为用户绘制对象的应用程序.我现在有一个这样的对象,它是由一个类型的数组构成的[UIBezierPath].然后我使用循环UIBezierPath将数组中的所有s 更改为CGPaths,然后想要逐个绘制那些路径的动画.但是,当我尝试使用此代码时,它不起作用,我无法在网上找到任何有用的信息.这是代码被使用来转换阵列macbookPath它由UIBezierPathCGPath:

for path in macbookPath {
        drawingPath.append(path.cgPath)
    }
Run Code Online (Sandbox Code Playgroud)

然后我使用此代码尝试绘制路径:

for cgPath in drawingPath {
        shapeLayer.path = cgPath
    }
Run Code Online (Sandbox Code Playgroud)

这是函数的其余代码,drawForm()它应该将表单绘制到一个名为的视图上aiDrawView:

@objc func drawForm() {
    var drawingPath = [CGPath]()
    var macbookPath = Forms.MacbookForm()
    let shapeLayer = CAShapeLayer()
    shapeLayer.frame = aiDrawView.bounds

    for path in macbookPath {
        drawingPath.append(path.cgPath)
    }

    for cgPath in drawingPath {
        shapeLayer.path = cgPath
    }

    let strokeEndAnimation = CABasicAnimation(keyPath: "strokeEnd")
    strokeEndAnimation.duration = 2.0
    strokeEndAnimation.fromValue …
Run Code Online (Sandbox Code Playgroud)

cabasicanimation cashapelayer cgpath uibezierpath swift

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

如何将动画化的 UIBezierPath 或 cgPath 翻转到 CAShapeLayer 上?

我有一个 [UIBezierPath] 类型的数组,我将其转换为 cgPaths,然后将其动画到我称为 shapeLayer 的 CAShapeLayer 上。现在由于某种原因我所有的路径都是颠倒的,所以所有的路径都被颠倒了。我该如何解决这个问题,我尝试了几种方法,但遗憾的是它们都不起作用......但是我确实弄清楚了如何扩展路径。这是我绘制 swiftPath 的代码,它是由函数 swiftBirdForm() 下的 Forms 类中找到的 UIBezierPaths 组成的路径。绘制路径工作正常,我只是不知道如何将其翻转 180 度。

    @objc func drawForm() {
    var swiftPath = Forms.swiftBirdForm()
    let shapeLayer = CAShapeLayer()
    shapeLayer.fillColor = UIColor.clear.cgColor
    shapeLayer.strokeColor = UIColor.black.cgColor
    shapeLayer.lineWidth = 1
    shapeLayer.frame = CGRect(x: -120, y: 120, width: 350, height: 350)

    var paths: [UIBezierPath] = swiftPath

    guard let path = paths.first else {
        return
    }

    paths.dropFirst()
        .forEach {
            path.append($0)
    }

    shapeLayer.transform = CATransform3DMakeScale(0.6, 0.6, 0)
    shapeLayer.path = path.cgPath

    self.view.layer.addSublayer(shapeLayer)

    let strokeEndAnimation = …
Run Code Online (Sandbox Code Playgroud)

cabasicanimation cashapelayer cgpath uibezierpath swift

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