IOS中的动画——Core Animation

iOS 核心动画 Core Animation浅谈 代码地址如下:http://www.demodashi.com/demo/11603.html 前记关于实现一个iOS动画,如果简单的,我们可以直接调用UIView的代码块来实现,虽然使用UIView封装的方法很方便,但是这只能用于一些简答的动画,如果是一些复杂的动画呢?这就不得不去研究下核心动画Core Animation(包含在Quartz Core框架中)了。这这之前我们必须了解,CALaye 阅读详情
一、基础动画 CABasicAnimation
1  //初始化方式
    CABasicAnimation * cabase=[CABasicAnimation animation];
2  //通过keyPath设置需要实现动画的属性,此处设为bounds
cabase.keyPath=@"bounds";
3 //通过toValue设置动画结束时候的状态
cabase.toValue=[NSValue valueWithCGRect:CGRectMake(0, 0, 10, 100)];
 //通过byValue设置每次改变的范围
cabase.byValue=[NSValue valueWithCGRect:CGRectMake(0, 0, 10, 100)];
//设置开始时候的状态
    cabase.fromValue=[NSValue valueWithCGPoint:CGPointMake(0, 0)];

4  //设置动画持续的时间
cabase.duration=2;
    //保存动画
   cabase.fillMode=kCAFillModeForwards;
    //保存设置不取消
   cabase.removedOnCompletion=NO;
[_layer addAnimation:cabase forKey:nil];

   案例:通过基础动画实现仿射变换动画

CABasicAnimation * cabase=[CABasicAnimation animation];
cabase.keyPath=@"transform";
cabase.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeScale(1, 2, 1)];
cabase.duration=2;
cabase.fillMode=kCAFillModeForwards;
  
    cabase.removedOnCompletion=NO;
[_layer addAnimation:cabase forKey:nil];
二、关键帧动画
1  //初始化方式
CAKeyframeAnimation * keyfram=[CAKeyframeAnimation animation];
2  //通过keyPath设置需要实现动画的属性,此处设为position
keyfram.keyPath=@"position";
3 //设置动画的需要经过的点
    CGPoint  p1=CGPointZero;
    CGPoint  p2=CGPointMake(150, 0);
    CGPoint  p3=CGPointMake(150, 150);
    CGPoint  p4=CGPointMake(0, 150);
    CGPoint  p5=CGPointZero;

    NSValue * v1=[NSValue valueWithCGPoint:p1];
    NSValue * v2=[NSValue valueWithCGPoint:p2];
    NSValue * v3=[NSValue valueWithCGPoint:p3];
    NSValue * v4=[NSValue valueWithCGPoint:p4];
NSValue * v5=[NSValue valueWithCGPoint:p5];
4 //将对应的值添加到动画并且设置动画保留
    keyfram.values=@[v1,v2,v3,v4,v5];
    keyfram.duration=1;
    keyfram.fillMode=kCAFillModeForwards;
    keyfram.removedOnCompletion=NO;
[_layer addAnimation:keyfram forKey:nil];

  案例:通过关键帧动画实现图片摇摆

  CAKeyframeAnimation * anima=[CAKeyframeAnimation animation];
    //通过设置放射变换的角度来实现
    anima.keyPath=@"transform.rotation";
    float p1=4/180.0*M_PI;
    anima.duration=0.2;
    anima.values=@[@(-p1),@(p1),@(-p1)];
    anima.fillMode=kCAFillModeForwards;
    anima.removedOnCompletion=NO;
    anima.repeatCount=MAXFLOAT;
    [_layer addAnimation:anima forKey:nil];
_layer.transform=CATransform3DMakeRotation(M_PI, 0, 0, 0);

 
三、转场动画
1  //初始化方式
CATransition * tran=[CATransition animation];
2  //设置动画效果
tran.type=@"rippleEffect";

//常用效果
kCATransitionFade
kCATransitionMoveIn
kCATransitionPush
kCATransitionReveal

3 //设置动画方向
tran.subtype=kCATransitionFromLeft;

//动画方向
kCATransitionFromRight
kCATransitionFromLeft
kCATransitionFromTop
kCATransitionFromBottom

4 //设置动画保留以及动画时长
  tran.fillMode=kCAFillModeForwards;
  tran.removedOnCompletion=NO;
  tran.duration=1;
  [self.myImageView.layer addAnimation:tran forKey:nil];
四、UIView封装动画

  UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画支持。执行动画所需要的工作由UIView类自动完成,但仍要在希望执行动画时通知视图,为此需要将改变属性的代码放在[UIViewbeginAnimations:nil context:nil]和[UIView commitAnimations]之间

   1、常见方法解析:

//设置动画代理
+ (void)setAnimationDelegate:(id)delegate  
 
//设置当动画即将开始时,执行delegate对象的selector,并且把beginAnimations:context:中传入的参数传进selector  
+(void)setAnimationWillStartSelector:(SEL)selector   

//设置动画结束时调用方法
+ (void)setAnimationDidStopSelector:(SEL)selector 

//设置动画持续时间
+(void)setAnimationDuration:(NSTimeInterval)duration  

//设置动画延迟
+ (void)setAnimationDelay:(NSTimeInterval)delay   

//设置动画开始时间
+ (void)setAnimationStartDate:(NSDate *)startDate

//设置动画节奏
+ (void)setAnimationCurve:(UIViewAnimationCurve)curve 

//设置动画重复次数
+ (void)setAnimationRepeatCount:(float)repeatCount 


//如果设置为YES,代表动画每次重复执行的效果会跟上一次相反
+(void)setAnimationRepeatAutoreverses:(BOOL)repeatAutoreverses 

// 设置视图view的过渡效果, transition指定过渡类型, cache设置YES代表使用视图缓存,性能较好
+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache 

  2、案例

   //旋转动画
    [UIView beginAnimations:@"roate" context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    [UIView setAnimationDuration:1.5];
     [UIView setAnimationDelegate:self];
    _view.transform=CGAffineTransformRotate(_view.transform, M_PI_2);
    [UIView setAnimationDidStopSelector:@selector(endAnimate)];
[UIView commitAnimations];
    //转场动画
[UIView beginAnimations:@"transition" context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:_mainView cache:YES];
    [UIView setAnimationDuration:1.5];
    NSInteger index1=[_mainView.subviews indexOfObject:_view];
    NSInteger index2=[_mainView.subviews indexOfObject:_view2];
    [_mainView exchangeSubviewAtIndex:index1 withSubviewAtIndex:index2];
    [UIView commitAnimations];

 

 

作者: 杰瑞教育
出处: http://blog.csdn.net/jerehedu
本文版权归烟台杰瑞教育科技有限公司和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
 
【iOS】一个取巧的弹出式动画实现以及后续的iOS动画学习(第一部分:基于CALayer的Core Animation框架) 二月中上班,开始开年需求,现在到三月初算是基本完成,也在测试之前趁着有那么一点空闲时间和精力记录下一些开发中遇到的问题。 这次记录下的是一个简单的动画效果实现。当时时间比较紧,用了一个取巧的动画实现(实际原因是没看懂CA动画怎么用),因此在这里记录下来,同时研究一下CA动画。 需求分析 (不知道怎么设置成循环,似乎只能刷新看一次) 这个动画效果分为两部分,要求其实有三: 1.图案从小... 阅读详情

相关推荐

iOS开发之核心动画(Core Animation)

1、概述       Core Animation是一个图形渲染和动画的底层框架,用于 iOS和Mac OS X。可以提供专业级的动画效果,是高层图形技术的基础。 2、使用        通过CALayer类实现,CALayerkey可以理解成是UIView的一个底层,

编码演绎世界 1130

IOS开发UI篇--IOS动画(Core Animation)总结

一、简介IOS 动画主要是指Core Animation框架。官方使用文档地址为:Core Animation Guide。Core Animation是IOS和OS X平台上负责图形渲染与动画的基础框架。Core Animation可以作用与动画视图或者其他可视元素,为你完成了动画所需的大部分绘帧工作。你只需要配置少量的动画参数(如开始点的位置和结束点的位置)即可使用Core Animation的

yixiangboy的博客 2万+

iOS 核心动画(Core Animation)一:初识

核心动画(Core Animation)一:初识简介继承关系图层(CALayer)图层继承关系图层提供绘图和动画的基础图层(CALayer)与视图(View)之间的关系图层使用两种类型的坐标系坐标点(position)锚点(anchorPoint)在三个维度上操纵图层更改UIView使用的图层类使用图像作为图层的内容使用委托提供图层内容 简介 Core Animation是可在iOS和OS X上使用的图形渲染和动画基础结构,可用于为应用程序的视图和其他视觉元素制作动画。使用Core Animation,绘制

wahkim的博客 579

Core Animation(一)iOS图形和动画的初步认识

一、行业及平台情况分析 在中国,一些发达城市,例如北、上、广、深,都处于经济高速发展阶段,而人们的生活也越发的忙碌,时间高度碎片化,所以人们没有很多时间坐在PC前,而都改用移动设备,甚至现在一些大公司的部分办公都依靠移动设备,所以移动开发是将来一段时间的必然趋势。 移动平台主要有iOS、Android以及其他,iOS一般定位于高端用户,Android面向高中低端用户,但高端用户较iOS偏少,甚

阿福的专栏 2243

iOS 核心动画(Core Animation)三:基础动画

核心动画(Core Animation)三:基础动画(CABasicAnimation) 简介CABasicAnimation与CAAnimation继承关系## CALayer 动画属性CABasicAnimation 属性列表CASpringAnimation 属性列表动画实例基础动画弹簧动画 简介 修改图层属性并提供基本的单关键帧动画功能的对象。 CABasicAnimation与CAAnimation继承关系 ## CALayer 动画属性 anchorPoint backgroundColor

wahkim的博客 542

UE5在Ubuntu22.04.4下的高效开发环境配置指南

本文详细介绍了在Ubuntu 22.04.4系统上配置UE5高效开发环境的完整指南,包括系统准备、显卡驱动安装、UE5引擎编译与配置、开发工具链设置以及性能优化技巧。通过逐步指导,帮助开发者快速搭建稳定的UE5开发环境,解决常见问题,提升开发效率。

weixin_29251131的博客 387

如何在ios中运用core animation暂停和继续动画

暂停和继续动画的核心代码如下://暂停layer上面的动画 - (void)pauseLayer:(CALayer*)layer { CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil]; layer.speed = 0.0; layer.timeOffset =

甘橙移动应用团队 1万+

Ansys Zemax与Speos协同设计:HUD系统从光学优化到驾驶视觉验证全流程解析

本文详细解析了如何利用Ansys Zemax与Speos协同工作流,完成HUD系统从光学内核优化到驾驶视觉验证的全流程。通过Zemax进行精密光学设计与像差校正,再通过Speos进行HOA定量分析和虚拟驾驶舱仿真,实现了数据无损流转与验证闭环,有效解决了光学性能与视觉感知脱节的核心问题,显著提升HUD设计效率与可靠性。

git9versioner的博客 536

在ios中运用core animation暂停和继续动画

核心代码如下 //暂停layer上面的动画 - (void)pauseLayer:(CALayer*)layer {     CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];     layer.speed = 0.0;     layer.timeOffset

IOS研究专栏 2513

基于STM32的最简易蓝牙遥控小车

基于STM32的蓝牙遥控小车,基于HAL库编写代码,具有移动功能,读者可自行添加其他扩展功能。按下状态的对应关系:2前进,4左转,5停止,6右转,8后退,松开状态都是5,都选择16进制。首先按照小车的图纸把小车的机械部分装好。做这个小车的成本在200元左右,包括焊接设备,杜邦线等。

weixin_43469377的博客 1万+

关于RT-Thread中PWM无法正常输出的学习

按照官方的PWM配置,并没有输出PWM,网上有比较多的办法,试了很多,有些还是不能实现输出,这里做个记录。记录自己完成PWM输出的过程,以及修改的地方。 关于STM32CubeMX配置就不多说了,网上有很多。 首先必定是按照流程来,一定一定按照流程来!!! 需要注意的是加上通道数!!!! 这是流程上没有的,也是RTT的一点小BUG吧 配上board.c中添加的代码,我用的是PA2定时2的通道3,需要使用的朋友修改对应定时器和GPIO! void HAL_TIM_Base_MspInit(TIM_Han

weixin_42566346的博客 3558

iOS动画集锦(Core Animation)

iOS 动画主要是指 Core Animation 框架, Core Animation是 iOS 和 OS X 平台上负责图形渲染与动画的基础框架。Core Animation 可以作用于动画视图或者其他可视元素,可以完成动画所需的大部分绘帧工作。Core Animation 系统已经进行了封装, 所以在使用的时候你只需要配置少量的动画参数(如开始点的位置和结束点的位置)即可使用 Core Animation 的多种动画效果。Core Animation 将大部分实际的绘图任务交给了图形硬件(GPU)来.

xuziwan562154119的专栏 357

最佳RANSAC算法拟合矩形的实现(基于PCL库)

最佳RANSAC算法是一种常用的参数估计方法,用于从数据集中拟合出最佳的模型。在计算机视觉和图像处理领域,最佳RANSAC算法常用于拟合几何形状,如矩形。本文将详细介绍如何使用点云库(PCL)中的最佳RANSAC算法来拟合矩形,并提供相应的源代码。

JbPatch的博客 1547

iOS边城之动画编程(Core Animation)

QuartzCore.framework     前缀名:CAXXX     参考:官方译 iOS开发之让你的应用“动”起来 cocoachina   简单一例 [UIView beginAnimations:nil context:nil];//开始动画 //修改x,此处的x属性为扩展的Category self.testView.x +=100; [UIView commitAn

mokai 2734

微信小程序 - 最新详细实现气泡菜单功能,点击任意元素在底部或附近周围弹出气泡菜单列表,仿微信气泡弹框显示菜单快捷功能收纳,自定义气泡弹窗/菜单气泡弹窗,小程序气泡框嵌套菜单组件插件,自动计算弹出定位

微信小程序,vue2,vue3,气泡列表,汽泡菜单,气泡框,泡泡框,悬浮框,悬浮菜单,点击菜单按钮弹出气泡,对话箭头气泡框,弹出的气泡准确定位并吸附在附近,弹出式气泡,弹窗菜单,气泡自定义HTML弹窗,带三角的气泡弹框,三角气泡框里面嵌套菜单,当点击一个按钮或元素时,会从附近弹出一个小气泡一样的菜单列表,自定义气泡框内的内容,点击一个元素在附近弹出一个气泡弹框功能效果,气泡弹框不准怎么办,被盖住了,挡住了,长按弹出,组件插件,微信,自定义气泡菜单组件,气泡弹出框,小程序自定义气泡框,菜单气泡,包裹列表的三角

🏆 前端领域优质创作者 3935

2024-12月js逆向案例-sensor-data之vmp字段之akamai_2/3.0-(下)

akamai2/3的vmp字段逆向分析

十一姐的博客 3151

探索 iOS Core Animation:解锁动画之美

探索 iOS Core Animation:解锁动画之美 iOS 应用开发中,Core Animation 是一个至关重要的框架,它赋予开发者强大的能力去创建出流畅、细腻的视觉效果。今天我们要深入了解一下由社区成员 AlfredTheBest 维护的开源项目 ,它是一个专为 iOS 开发者打造的 Core Animation 实践教程和示例库。 项目简介 项目是一个集合了多种 Core Anim...

gitblog_00019的博客 839

openclaw-cn : 无法将“openclaw-cn”项识别为 cmdlet、函数、脚本文件或可运行程序的名称 解决方案

本文主要介绍了openclaw-cn : 无法将“openclaw-cn”项识别为 cmdlet、函数、脚本文件或可运行程序的名称解决方案,希望能对使用openclaw-cn的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 10万+

告别动画卡顿:XcodeGen+Core Animation构建丝滑iOS应用全指南

你是否曾为动画项目的配置复杂性而头疼?在iOS开发中,Core Animation(核心动画)是实现流畅视觉效果的基石,但项目配置的繁琐和性能优化的挑战常常让开发者望而却步。本文将展示如何通过XcodeGen实现动画项目的自动化配置,并结合Core Animation的性能优化策略,让你的动画应用在各种设备上保持60fps的丝滑体验。读完本文,你将掌握: - XcodeGen的动画项目配置最佳实...

gitblog_00391的博客 1049

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

IOS动画总结-Core Animation

一、简介  IOS 动画主要是指Core Animation框架。官方使用文档地址为:Core Animation Guide。 Core Animation是IOS和OS X平台上负责图形渲染与动画的基础框架。Core Animation可以作用与动画视图或者其他可视元素,为你完成了动画所需的大部分绘帧工作。你只需要配置少量的动画参数(如开始点的位置和结束点的位置)即可使用Core

PRliu的博客 830

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

【iOS】动画(Core Animation)总结

转载地址 iOS动画(Core Animation)总结

Hanrovey Blog 341

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

acwj常量折叠优化教程:让手写编译器自动生成更优代码的进阶技巧

acwj(A Compiler Writing Journey)是一个循序渐进的手写 C 语言子集编译器项目,其第 44 部分实现了**常量折叠(Constant Folding)**优化:让编译器在编译期直接算出 `2000 + 3 + 4 * 5 + 6` 这类纯常量表达式的值,从而生成更精简、更高效的汇编代码。本教程带你理解这套优化如何落地。 [![acwj编译器常量折叠优化中的AST表达

gitblog_00227的博客 371

iOS第十七篇 动画可以通过 UIKit 和 Core Animation 框架来实现

上述代码中,通过UIView.animate方法设置动画的持续时间和要改变的属性(这里是视图的transform属性来实现缩放),实现了视图的放大和缩小动画,并通过递归使其循环进行。基础动画(CABasicAnimation):基础动画通过属性修改进行动画参数控制,只有初始状态和结束状态。UIView 提供了简单便捷的动画方法,适合实现一些基础的动画效果。代码中创建了两个基础动画,一个用于改变位置,一个用于改变透明度,然后将它们添加到动画组中一起执行。Core Animation 动画。

I_did_it的博客 871

iOS——Core Animation(核心动画)

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34087503的博客 205

iOS动画(Core Animation总结)

一、简介 iOS 动画主要是指Core Animation框架。官方使用文档地址为:Core Animation Guide。 Core Animation是IOS和OS X平台上负责图形渲染与动画的基础框架。Core Animation可以作用与动画视图或者其他可视元素,为你完成了动画所需的大部分绘帧工作。你只需要配置少量的动画参数(如开始点的位置和结束点的位置)即可使用Core A

Nicholas的专栏 774
上一篇: Android studio导入开源项目
下一篇: Android制作曲线、柱状图、饼形等图表——使用AChartEngine
「已注销」
博客等级 码龄12年 101粉丝 161原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值