- 博客(89)
- 资源 (1)
- 收藏
- 关注
原创 python精要(66)—类(3)-文档字符串,注释文档
#!/usr/bin/env python3# -*- coding: utf-8 -*-"""Created on Mon Feb 22 08:35:42 2021@author: myhaspl"""class Point: def __new__(cls,x=0,y=0): 'new调用此方法后,再调用__init__构造函数,可在此方法中对父类的__new__方法进行调用' print("new") return object
2021-02-28 15:24:30 193
原创 PyTorch随笔-4
import torchprint(torch.zeros(2,3,2))print(torch.ones(2,4))print(torch.eye(5))#对象线为1,其余为0,单位矩阵print(torch.rand(2,3))#[0,1]随机数print(torch.arange(2,8))#序列print(torch.arange(2,10,3))tensor([[[0., 0.], [0., 0.], [0., 0.]], [[
2021-02-28 14:51:09 192
原创 erlang精要(25)-映射组(键值对)的建立及更新、匹配及使用
9> Y1=#{a=>12,b=>16}. #{a => 12,b => 16}10> Y2=#{c=>120,d=>160}.#{c => 120,d => 160}11> Y2.#{c => 120,d => 160}12> Y1.#{a => 12,b => 16}13> Y3=Y2.#{c => 120,d => 160}14> Y3.#{c => 12
2021-02-28 11:11:02 377
原创 erlang精要(24)-取消记录格式
1> rr("learnerl.hrl").[student]2> #student{}.#student{name = undefined,age = undefined,class = undefined}3> X1=#student{name=zhangsang,age=25,class=computer}.#student{name = zhangsang,age = 25,class = computer}6> X1.#student{name = zhang
2021-02-28 11:01:44 155
原创 c++17(30)-文件读写(1)
以带成员函数的struct为例,演示一下二进制文件的读写。1、std::ifstream对文件进行操作的输入流类。此类的对象维护一个filebuf对象作为其内部流缓冲区,该缓冲区对与其关联的文件(如果有的话)执行输入/输出操作。文件流在构造时或通过调用member open与文件相关联。typedef basic_ifstream<char> ifstream;这是带有以下模板参数的basic_ifstream 的实例化:模板参数定义注释charT char别名为成员char
2021-02-27 23:12:13 973
原创 c++17(29)-标量、结构体与数组的new与delete
0000000123401234Hit any key to continue...#include <iostream>using namespace std;typedef struct DataStorage{ int id; int size; int next; unsigned char*data;} Data;int main(int argc, char **argv){ int *x=ne
2021-02-27 13:07:18 247
原创 PyTorch随笔-3
特定数据类型的tensor可以被构造,通过 torch.dtype和/或torch.device,对于构造函数或张量创建操作。>>> cuda0 = torch.device('cuda:0')>>> torch.ones([2, 4], dtype=torch.float64, device=cuda0)tensor([[ 1.0000, 1.0000, 1.0000, 1.0000], [ 1.0000, 1.0000, 1.0000,
2021-02-25 20:22:20 168
原创 erlang精要(23)-erl(2)
(base) [myhaspl@localhost erl]$ cd learnerl(base) [myhaspl@localhost learnerl]$ lslearnerl.beam learnerl.erl learnerl.hrl(base) [myhaspl@localhost learnerl]$ rm *.beam(base) [myhaspl@localhost learnerl]$ lslearnerl.erl learnerl.hrl(base) [myhaspl@
2021-02-25 18:44:23 160
原创 PyTorch随笔-2
torch.Tensor 是torch.FloatTensor的别名。tensor可用Python list或sequence 使用torch.tensor()进行构造。import torchx=torch.tensor([[10,20],[2,4]])print(x)tensor([[10, 20], [ 2, 4]])import torcha=[[10.2,20.6],[2,4]]x=torch.DoubleTensor(a)print(x)y=torch.
2021-02-25 18:31:45 145
原创 PyTorch随笔-1
CLASS torch.Tensornew_tensor(data, dtype=None, device=None, requires_grad=False) → Tenso创建张量有几种主要方法,具体取决于您的用例。要使用预先存在的数据创建张量,请使用torch.tensor()要创建具有特定大小的张量,请使用torch.* tensor 创建操作。要创建一个与另一个张量具有相同大小(和类似类型)的张量,请使用torch.*_like 张量创建操作(请参阅creation ops)。要创
2021-02-25 11:30:06 184
原创 erlang精要(22)-归集器、记录
-module(learnerl).-export([odds_and_evens/1]).%程序:刘兴%https://aipro.blog.csdn.net/odds_and_evens(L)->odds_and_evens_acc(L,[],[]).odds_and_evens_acc([H|T],Odds,Evens)-> case (H rem 2) of 1->odds_and_evens_acc(T,[H|Odds],Evens);
2021-02-24 22:37:04 186
原创 python精要(65)-类(2)-构造函数
__init__(self[, ...])在实例创建( *__new__()*)之后调用,但在实例返回给调用方之前调用。#!/usr/bin/env python3# -*- coding: utf-8 -*-"""Created on Mon Feb 22 08:35:42 2021@author: myhaspl"""class Point: def init(self): self.x=0 self.y=0 def set(self,
2021-02-22 22:50:22 135 1
原创 python3精要(64)-类(1)-入门
#!/usr/bin/env python3# -*- coding: utf-8 -*-"""Created on Mon Feb 22 08:35:42 2021@author: myhaspl"""class LearnClass: passa=LearnClass()print(a)runfile('/home/myhaspl/learn/learnpy/learnpy1.py', wdir='/home/myhaspl/learn/learnpy')Reloade
2021-02-22 21:12:07 127
原创 erlang(21)-列表推导与计算素数与合数
1、参考知识:https://aipro.blog.csdn.net/article/details/1105308182、代码-module(learnerl).-export([is_prime_number/1,get_prime_nums/1]).%程序:刘兴%https://aipro.blog.csdn.net/is_ediv(A,L)-> io:format("~n~p:~n",[A]), GetRem=fun(X)->
2021-02-21 16:53:49 220
原创 erlang(20)-控制抽象与判断素数
定义自己的for产生序列-module(learnerl).-export([get_result/2]).for(Max,Max,F)->[F(Max)];for(I,Max,F)->[F(I)|for(I+1,Max,F)].output_lst([Fst|Rst])-> io:format("~p ",[Fst]), output_lst(Rst);output_lst([]) ->io:format("~n").get_res
2021-02-21 14:12:48 222
原创 erlang精要(19)-以函数作为参数的函数,返回函数的函数(2)
下面以一个综合例子来整合前一节的内容:以函数作为参数的函数返回函数的函数例子功能是完成求第一个参数列表能全部被第二个参数列表整除的元素。-module(learnerl).-export([get_result/2]).%程序:刘兴%https://aipro.blog.csdn.net/is_ediv(A,L)-> GetRem=fun(X)->(fun(Y)->(X rem Y) =:=0 end) end, lists:all(fun(X)->
2021-02-20 11:06:51 189
原创 erlang精要(18)-以函数作为参数的函数,返回函数的函数(1)
1> Is_odd =fun(X) -> (X rem 2) =:= 1 end.#Fun<erl_eval.44.79398840>2> Y=[1,2,3,4,5,6,7,8,9].[1,2,3,4,5,6,7,8,9]5> lists:map(Is_odd,Y).[true,false,true,false,true,false,true,false,true]6> lists:filter(Is_odd,Y).[1,3,5,7,9]Is_od
2021-02-19 10:31:47 267
原创 latex精要(1)-安装与helloworld
1、安装sudo yum install texlive sudo yum install tex*ctex*sudo yum install texwork2、第一个例子\documentclass[utf8]{ctexart}\begin{document}\section{中文} 您好,世界 \section{engish} hello,world\section{公式}\[a^2+b^2=c^2\]\end{document}...
2021-02-18 16:30:56 116
原创 erlang精要(17)-匿名函数多子句-多个激活函数实现
1、Sigmoid函数Sigmoid函数是一个在生物学中常见的S型函数,也称为S型生长曲线。在信息科学中,由于其单增以及反函数单增等性质,Sigmoid函数常被用作神经网络的阈值函数,将变量映射到0,1之间2、Tanh函数Tanh是双曲函数中的一个,Tanh()为双曲正切。在数学中,双曲正切“Tanh”是由基本双曲函数双曲正弦和双曲余弦推导而来。3、ReluRelu激活函数(The Rectified Linear Unit),用于隐层神经元输出。公式如下16> learner
2021-02-17 23:21:29 183
原创 javascript精要(3)-动态加载脚本
1、除了<script>标签,还可通过DOM API加载脚本2、例:let script=document.createElement('script');script.src='example.js';document.head.appendChild(script);这种方式是异步加载脚本的,所有浏览器都支持createElement,但党政所有浏览器都支持asyc属性。在将上述htmlElement元素增加到DOM且执行到这段代码之前不会发送请求。可明确设置同步加载let
2021-02-16 23:55:28 219
原创 erlang精要(16)-匿名函数之sigmoid函数实现
sigmoid函数也叫Logistic函数,用于隐层神经元输出,取值范围为(0,1),它可以将一个实数映射到(0,1)的区间,可以用来做二分类。45> c(learnerl).{ok,learnerl}46> learnerl:activation({xxx,12}).1247> learnerl:activation({xxx,1266}).126648> learnerl:activation({sigmoid,1266}).1.049> learner
2021-02-16 22:30:18 267
原创 erlang虚拟机精要(2)-异步信号&时间功能
2.3实现虚拟机中不同异步信号的实现可能会随着时间的推移而变化,但其行为总是遵循上述实体之间传递异步信号的概念。通过检查实现,您可能会注意到某些特定信号提供了比上面描述的更严格的保证。Erlang代码不能使用这些关于实现的知识,这一点非常重要,因为实现可以在任何时候改变而不需要事先通知。主要实施更改的例子:从ERTS 5.5.2起,到进程的退出信号是真正异步传递的。从ERTS 5.10开始,所有从进程到端口的信号都是真正异步传递的。...
2021-02-15 21:23:24 174
原创 erlang精要(15)-列表(2)与分号、逗号、句号
9> io:format("~w ~n",[98]).98 ok7> X1=[98,97,86]."baV"1、分号:分隔子句2、逗号:分隔函数调用3、句号:分隔函数整体
2021-02-13 22:09:59 172
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人