-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
readonly base_dir="/home/imagine/cnn/scripts" | ||
readonly hws_dir="/home/imagine/cnn/hws" | ||
function do_something(){ | ||
echo hola | ||
echo $1 | ||
echo $2 | ||
echo | ||
#cd $hws_dir | ||
#cd $1 | ||
#gedit $2.m | ||
cd $base_dir | ||
./run_mat.sh $1 $2 | ||
} | ||
|
||
function main(){ | ||
|
||
while read p; do | ||
do_something $p | ||
done < train_funcs.txt | ||
|
||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
readonly matlab="/usr/local/MATLAB/R2014b/bin/matlab" | ||
readonly ml_flags="-nodesktop -noFigureWindows -nosplash" | ||
readonly t_limit="4h" | ||
readonly base_dir="/home/imagine/cnn/hws" | ||
readonly mega_log="/home/imagine/cnn/scripts/mega_log.txt" | ||
|
||
function main(){ | ||
local folder=$1 | ||
local script=$2 | ||
|
||
cd $base_dir | ||
cd $folder | ||
|
||
rm -rf "textons-experiment" | ||
rm "train_log.txt" | ||
local command="$matlab $ml_flags -logfile train_log.txt -r $script" | ||
echo $command | ||
echo -e "\n\n $folder \n =========================\n$command \n\n ">> $mega_log | ||
|
||
timeout -s1 --foreground $t_limit $command <<< "exit" | ||
#$command | ||
|
||
echo -e "\n -Time is up- \n" >> train_log.txt | ||
|
||
cat train_log.txt >> $mega_log | ||
|
||
} | ||
|
||
main $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
function setup_dir(){ | ||
|
||
local target_dir=$1 | ||
readonly base_dir=/home/imagine/cnn/practical | ||
ln -s $base_dir/* $target_dir | ||
} | ||
|
||
function setup_all(){ | ||
local all_dirs=$(ls -1 $1) | ||
for d in ${all_dirs}; do | ||
echo $1/$d | ||
setup_dir $1/$d | ||
done | ||
} | ||
|
||
function main(){ | ||
if [ $# -ne 1 ]; then | ||
echo Requires one argument | ||
else | ||
if [ -d $1 ]; then | ||
setup_all $1 | ||
else | ||
echo $1 is not a directory | ||
fi | ||
fi | ||
|
||
|
||
|
||
} | ||
main $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
for i = 1:length(dir_names) | ||
n=dir_names(i).name; | ||
try | ||
s=test_net(n); | ||
catch | ||
s=0; | ||
end | ||
course_scores{i}=struct('name',n,'score',s) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function total_score=test_net(folder) | ||
%run('/home/imagine/cnn/practical/setup.m'); | ||
test_db=load('home/imagine/cnn/scripts/test_textons'); | ||
cd('/home/imagine/cnn/hws'); | ||
cd(folder) | ||
cd textons-experiment | ||
epochs=dir('net-epoch-*.mat'); | ||
net_t=load(epochs(end).name); | ||
net=net_t.net; | ||
if strcmp(net.layers{end}.type, 'softmaxloss') | ||
net.layers(end)=[]; | ||
end | ||
|
||
total_score=0; | ||
for i=1:length(test_db.patches) | ||
label=test_db.labels(1); | ||
p0=test_db.patches{i}; | ||
p1=reshape(p0,128,128,1,[]); | ||
res=vl_simplenn(net,p1); | ||
resl=squeeze(res(end).x); | ||
score=zeros(size(p0,3),1); | ||
pred=score; | ||
for j=1:size(resl,2) | ||
[score(j),pred(j)]=max(resl(:,j)); | ||
end | ||
round_score=sum(pred==label); | ||
total_score=total_score+ round_score; | ||
end |