我的应用程序中有一个滚动视图的视图(百分比计算器).我试图动画视图飞出然后从左边再次飞入,虽然有不同的内容,按一下按钮.这是我的代码:
func next()
{
UIView.animateWithDuration(0.5, animations: {
self.mainView.frame = CGRectMake(-500, self.view.bounds.height/2-self.mainHeight/2, self.mainWidth, self.mainHeight)
self.mainView.center.x -= 600
}) { (success) in
self.mainView.center.x += 1200
}
UIView.animateWithDuration(0.5, animations: {
self.mainView.frame = CGRectMake(self.view.bounds.width/2-self.mainWidth/2, self.view.bounds.height/2-self.mainHeight/2, self.mainWidth, self.mainHeight)
}) { (success) in
print("Animation Successful!")
self.drawView()
}
}
Run Code Online (Sandbox Code Playgroud)
我不明白为什么,但动画没有发生,视图完全消失,我"Animation Successful"在日志中看到.为了清楚起见,我以编程方式创建了视图.
这是viewDidLoad()中的代码; 调用时视图显示正确:
mainHeight = self.view.bounds.height * 0.85
mainWidth = self.view.bounds.width * 0.85
let viewHeight = self.view.bounds.height
let viewWidth = self.view.bounds.width
mainView.frame = CGRectMake(viewWidth/2-mainWidth/2, viewHeight/2-mainHeight/2, mainWidth, mainHeight)
mainView.layer.cornerRadius = 8
mainView.layer.masksToBounds = true
mainView.backgroundColor = …Run Code Online (Sandbox Code Playgroud) 我正在训练一个具有 2 个类和 53k 图像的图像分类器,并使用 keras 用 1.3k 图像对其进行验证。这是神经网络的结构:
model = Sequential()
model.add(Flatten(input_shape=train_data.shape[1:]))
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))
model.compile(optimizer='adam',
loss='binary_crossentropy', metrics=['accuracy'])
Run Code Online (Sandbox Code Playgroud)
在第一个 epoch 中,训练准确度从 ~50% 增加到 ~85%,验证准确度为 85%。随后的 epoch 不断提高训练准确度,但是,验证准确度保持在 80-90% 的范围内。
我很好奇,是否有可能在第一个 epoch 中获得高验证和训练准确率?如果我的理解是正确的,它会从小处开始,并随着每个经过的时代稳步增加。
谢谢
编辑:重新缩放后图像大小为 150x150,小批量大小为 16。
我编写了以下代码来下载并在tableView的单元格中显示图像.然而,投影根本没有出现,我无法弄清楚出了什么问题.
cell.societyImage.setIndicatorStyle(UIActivityIndicatorViewStyle.White)
cell.societyImage.setShowActivityIndicatorView(true)
cell.societyImage.sd_setImageWithURL(NSURL(string: pictureURLs[objectIds[indexPath.row]]!),completed: { (image, error, cache, url) in
cell.societyImage.layer.shadowColor = UIColor(white: 0.7, alpha: 0.7).CGColor
cell.societyImage.layer.shadowOffset = CGSizeMake(3, 3)
cell.societyImage.layer.shadowOpacity = 0.4
cell.societyImage.layer.masksToBounds = true
})
Run Code Online (Sandbox Code Playgroud)
任何帮助深表感谢!
ios ×2
swift ×2
animation ×1
keras ×1
python ×1
shadow ×1
tensorflow ×1
uianimation ×1
uiimageview ×1
uiview ×1