以下类具有let声明为隐式展开变量的' '属性.以前这适用于Xcode 6.2:
class SubView: UIView {
let pandGestureRecognizer: UIPanGestureRecognizer!
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.pandGestureRecognizer = UIPanGestureRecognizer(target: self, action: "panAction:")
}
func panAction(gesture: UIPanGestureRecognizer) {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
更新到Xcode 6.3(使用Swift 1.2)后,会发生以下编译错误:
Property 'self.panGestureRecognizer' not initialized at super.init call
Immutable value 'self.panGestureRecognizer' may only be initialized once
Run Code Online (Sandbox Code Playgroud)
在super.init通话前移动以下行:
self.pandGestureRecognizer = UIPanGestureRecognizer(target: self, action: "panAction:")
Run Code Online (Sandbox Code Playgroud)
给出以下错误:
'self' is used before super.init call
Run Code Online (Sandbox Code Playgroud)
该属性' panGestureRecognizer'不需要变异,因此必须将其声明为常量' let'.由于它是常量,因此必须在声明时具有初始值,或者在init方法中初始化它.要初始化它,需要self在' target'参数中传递' ' …
我正在尝试堆叠2层来tf.nn.conv2d_transpose()对张量进行上采样.它在前馈期间工作正常,但在向后传播时出现错误:
ValueError: Incompatible shapes for broadcasting: (8, 256, 256, 24) and (8, 100, 100, 24).
基本上,我只是将第一个的输出设置conv2d_transpose为第二个的输入:
convt_1 = tf.nn.conv2d_transpose(...)
convt_2 = tf.nn.conv2d_transpose(conv_1)
Run Code Online (Sandbox Code Playgroud)
只使用一个conv2d_transpose,一切正常.只有多个conv2d_transpose堆叠在一起时才会出现错误.
我不确定实现多层的正确方法conv2d_transpose.任何关于如何解决这个问题的建议都将非常感激.
这是一个复制错误的小代码:
import numpy as np
import tensorflow as tf
IMAGE_HEIGHT = 256
IMAGE_WIDTH = 256
CHANNELS = 1
batch_size = 8
num_labels = 2
in_data = tf.placeholder(tf.float32, shape=(batch_size, IMAGE_HEIGHT, IMAGE_WIDTH, CHANNELS))
labels = tf.placeholder(tf.int32, shape=(batch_size, IMAGE_HEIGHT, IMAGE_WIDTH, 1))
# Variables
w0 = tf.Variable(tf.truncated_normal([3, 3, CHANNELS, …Run Code Online (Sandbox Code Playgroud)