📝 update stl/file and test files.
This commit is contained in:
parent
24ba300f3c
commit
0e578b3e21
22
stl/file.nas
22
stl/file.nas
|
@ -36,3 +36,25 @@ var find_all_files=func(path){
|
|||
unix.closedir(dd);
|
||||
return res;
|
||||
}
|
||||
|
||||
var recursive_find_files=func(path){
|
||||
if(!io.exists(path))
|
||||
return nil;
|
||||
var dd=unix.opendir(path);
|
||||
var res={
|
||||
dir:path,
|
||||
files:[]
|
||||
};
|
||||
while(var n=unix.readdir(dd)){
|
||||
if(unix.isfile(path~"/"~n)){
|
||||
append(res.files,n);
|
||||
}elsif(unix.isdir(path~"/"~n) and n!="." and n!=".."){
|
||||
var tmp=recursive_find_files(path~"/"~n);
|
||||
if(tmp!=nil)
|
||||
append(res.files,tmp);
|
||||
}
|
||||
|
||||
}
|
||||
unix.closedir(dd);
|
||||
return res;
|
||||
}
|
10
test/bp.nas
10
test/bp.nas
|
@ -26,7 +26,7 @@ var diffsigmoid=func(x){
|
|||
return x*(1-x);
|
||||
}
|
||||
|
||||
var (inum,hnum,onum)=(2,4,1);
|
||||
var (inum,hnum,onum)=(2,5,1);
|
||||
var training_set=[[0,0],[0,1],[1,0],[1,1]];
|
||||
var expect=[0,1,1,0];
|
||||
|
||||
|
@ -112,8 +112,14 @@ while(error>0.0005){
|
|||
backward(i);
|
||||
}
|
||||
cnt+=1;
|
||||
if(cnt>=3e5)
|
||||
break;
|
||||
}
|
||||
if(cnt>=3e5){
|
||||
print("failed to train, ",cnt," epoch.\n");
|
||||
}else{
|
||||
print('finished after ',cnt,' epoch.\n');
|
||||
}
|
||||
print('finished after ',cnt,' epoch.\n');
|
||||
foreach(var v;training_set){
|
||||
run(v);
|
||||
print(v,': ',output[0].out,'\n');
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
var fd=io.open("test/filesystem.nas");
|
||||
while((var line=io.readln(fd))!=nil)
|
||||
println(line);
|
||||
io.close(fd);
|
||||
println(io.stat("test/filesystem.nas"));
|
||||
|
||||
var files=func(dir){
|
||||
var dd=unix.opendir(dir);
|
||||
var files=func(path){
|
||||
if(!io.exists(path))
|
||||
return [];
|
||||
var dd=unix.opendir(path);
|
||||
var res=[];
|
||||
while(var n=unix.readdir(dd))
|
||||
append(res,n);
|
||||
|
@ -22,17 +18,19 @@ var prt=func(s,path){
|
|||
foreach(var j;s)
|
||||
print("\e[34m",j,"\e[0m");
|
||||
if(unix.isdir(path~"/"~f)){
|
||||
println("\e[34m",i==last?"└─":"├─","\e[0m\e[36m",f," >\e[0m");
|
||||
append(s,i==last?" ":"│ ");
|
||||
println("\e[34m",i==last?" └─":" ├─","\e[0m\e[36m[",f,"]>\e[0m");
|
||||
append(s,i==last?" ":" │ ");
|
||||
prt(s,path~"/"~f);
|
||||
pop(s);
|
||||
}elsif(unix.isfile(path~"/"~f)){
|
||||
println("\e[34m",i==last?"└─":"├─","\e[0m\e[32m",f,"\e[0m");
|
||||
println("\e[34m",i==last?" └─":" ├─","\e[0m\e[32m",f,"\e[0m");
|
||||
}else{
|
||||
println("\e[34m",i==last?"└─":"├─","\e[0m\e[91m",f,"\e[0m");
|
||||
println("\e[34m",i==last?" └─":" ├─","\e[0m\e[91m",f,"\e[0m");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println("\e[36mNasal-Interpreter >\e[0m");
|
||||
if(os.platform()=="windows")
|
||||
system("chcp 65001");
|
||||
println("\e[36m[",unix.getcwd(),"]>\e[0m");
|
||||
prt([""],".");
|
Loading…
Reference in New Issue