Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kiryuu Sakuya
TensorFlow-Homework
Commits
391051e1
Unverified
Commit
391051e1
authored
Apr 14, 2020
by
Kiryuu Sakuya
🎵
Browse files
Fix typo
parent
f5fb10ab
Changes
13
Hide whitespace changes
Inline
Side-by-side
exam/step10/AnsAlexNet.py
View file @
391051e1
import
sys
import
tensorflow
as
tf
import
os
os
.
environ
[
\
"TF_CPP_MIN_LOG_LEVEL
\
"
]='3'
os
.
environ
[
"TF_CPP_MIN_LOG_LEVEL"
]
=
'3'
import
warnings
warnings
.
filterwarnings
(
'ignore'
)
sys
.
path
.
append
(
'step3'
)
...
...
@@ -85,5 +85,5 @@ with tf.Session() as sess:
print
(
'current accuracy: '
,
str
(
acc_v
))
# if acc_v \u003e 0.7 and acc_v \u003e max_acc:
# max_acc = acc_v
# saver.save(sess,
\
"
step10/Model/FinalNet
\
"
)
# saver.save(sess, "step10/Model/FinalNet")
#********** End **********#
\ No newline at end of file
exam/step10/AnsInception.py
View file @
391051e1
...
...
@@ -80,5 +80,5 @@ with tf.Session() as sess:
if
acc_v
\
u003e
0.7
and
acc_v
\
u003e
max_acc
:
max_acc
=
acc_v
saver
.
save
(
sess
,
\
"step10/Model/FinalNet
\
"
)
saver
.
save
(
sess
,
"step10/Model/FinalNet"
)
exam/step10/AnsResNet.py
View file @
391051e1
...
...
@@ -89,4 +89,4 @@ with tf.Session() as sess:
if
acc_v
\
u003e
0.7
and
acc_v
\
u003e
max_acc
:
max_acc
=
acc_v
saver
.
save
(
sess
,
\
"step10/Model/FinalNet
\"
)
\ No newline at end of file
saver
.
save
(
sess
,
"step10/Model/FinalNet"
)
\ No newline at end of file
exam/step10/TrainSaveLoadForUsers.py
View file @
391051e1
import
os
os
.
environ
[
\
"TF_CPP_MIN_LOG_LEVEL
\
"
]='3'
os
.
environ
[
"TF_CPP_MIN_LOG_LEVEL"
]
=
'3'
import
warnings
warnings
.
filterwarnings
(
'ignore'
)
...
...
exam/step10/TraubSaveLoadTest.py
View file @
391051e1
import
os
os
.
environ
[
\
"TF_CPP_MIN_LOG_LEVEL
\
"
]='3'
os
.
environ
[
"TF_CPP_MIN_LOG_LEVEL"
]
=
'3'
import
warnings
warnings
.
filterwarnings
(
'ignore'
)
...
...
@@ -25,19 +25,19 @@ with tf.Session() as sess:
# for op in graph.get_operations():
# print(op.name)
# mm = graph.get_tensor_by_name(
\
"
batch_normalization/moving_mean:0
\
"
)
# mm = graph.get_tensor_by_name("batch_normalization/moving_mean:0")
# print(sess.run(mm))
# exit()
G_Valid
=
batchGenerator
(
batchSize
=
8
,
basePath
=
'data/processed/valid_224'
)
X_v
,
Y_v
=
G_Valid
.
getBatch
()
batchImgInput = graph.get_tensor_by_name(
\
"
batchImgInput:0
\
"
)
labels = graph.get_tensor_by_name(
\
"
Labels:0
\
"
)
keeProb = graph.get_tensor_by_name(
\
"
dropout_keep_prob:0
\
"
)
batchImgInput
=
graph
.
get_tensor_by_name
(
"batchImgInput:0"
)
labels
=
graph
.
get_tensor_by_name
(
"Labels:0"
)
keeProb
=
graph
.
get_tensor_by_name
(
"dropout_keep_prob:0"
)
try
:
BNTraining = graph.get_tensor_by_name(
\
"
BNTraining:0
\
"
)
batchSize = graph.get_tensor_by_name(
\
"
InputBatchSize:0
\
"
)
BNTraining
=
graph
.
get_tensor_by_name
(
"BNTraining:0"
)
batchSize
=
graph
.
get_tensor_by_name
(
"InputBatchSize:0"
)
except
:
BNTraining
,
batchSize
=
None
,
None
...
...
@@ -52,7 +52,7 @@ with tf.Session() as sess:
else
:
feed_dict
=
{
batchImgInput
:
X_v
,
labels
:
Y_v
,
keeProb
:
1.
}
out = graph.get_tensor_by_name(
\
"
model_outputs/BiasAdd:0
\
"
)
out
=
graph
.
get_tensor_by_name
(
"model_outputs/BiasAdd:0"
)
output_v
=
softmax
(
sess
.
run
(
out
,
feed_dict
=
feed_dict
))
...
...
exam/step3/generatorForUsers.py
View file @
391051e1
...
...
@@ -11,7 +11,7 @@ class batchGenerator:
def
__init__
(
self
,
basePath
=
'data/processed/train_224/'
,
batchSize
=
256
):
'''
数据集中有四类图片分别是'bus','family sedan','fire engine','racing car',
每个图片的文件名形式为
\
"
XXX (id).jpg
\
"
或
\
"
XXX (id)_flipx.jpg
\
"
,例如
\
"
bus (1).jpg
\
"
,
\
"
bus (1)_flipx.jpg
\
"
每个图片的文件名形式为"XXX (id).jpg"或"XXX (id)_flipx.jpg",例如"bus (1).jpg","bus (1)_flipx.jpg"
:param basePath:数据集路径
:param batchSize: 每次获取的图片数量
...
...
exam/step4/AlexNetCompleted.py
View file @
391051e1
import
tensorflow
as
tf
import
os
# os.environ[
\
"TF_CPP_MIN_LOG_LEVEL
\
"]='3'
# os.environ["TF_CPP_MIN_LOG_LEVEL"]='3'
#----以下是答案部分 begin----#
# 定义placeholder 开始
...
...
@@ -62,7 +62,7 @@ train = tf.train.AdamOptimizer().minimize(loss)
with
tf
.
Session
()
as
sess
:
sess
.
run
(
tf
.
global_variables_initializer
())
tf
.
train
.
export_meta_graph
(
filename
=
\
"step4/modelInfo/AlexNet
\
"
,
tf
.
train
.
export_meta_graph
(
filename
=
"step4/modelInfo/AlexNet"
,
graph
=
tf
.
get_default_graph
())
tf
.
reset_default_graph
()
\ No newline at end of file
exam/step4/AlexNetForUsers.py
View file @
391051e1
...
...
@@ -52,5 +52,5 @@ import tensorflow as tf
#---否则影响测评---#
with
tf
.
Session
()
as
sess
:
sess
.
run
(
tf
.
global_variables_initializer
())
tf
.
train
.
export_meta_graph
(
filename
=
\
"step4/userModelInfo/AlexNet
\
"
,
tf
.
train
.
export_meta_graph
(
filename
=
"step4/userModelInfo/AlexNet"
,
graph
=
tf
.
get_default_graph
())
\ No newline at end of file
exam/step4/AlexNetTest.py
View file @
391051e1
import
os
os
.
environ
[
\
"TF_CPP_MIN_LOG_LEVEL
\
"
]='3'
os
.
environ
[
"TF_CPP_MIN_LOG_LEVEL"
]
=
'3'
import
warnings
warnings
.
filterwarnings
(
'ignore'
)
...
...
exam/step6/VGGNetCompleted.py
View file @
391051e1
...
...
@@ -54,8 +54,8 @@ train = tf.train.AdamOptimizer().minimize(loss)
with
tf
.
Session
()
as
sess
:
sess
.
run
(
tf
.
global_variables_initializer
())
# saver.save(sess,
\
"modelInfo/VGGNet
\
")
tf
.
train
.
export_meta_graph
(
filename
=
\
"step6/modelInfo/VGGNet
\
"
,
# saver.save(sess, "modelInfo/VGGNet")
tf
.
train
.
export_meta_graph
(
filename
=
"step6/modelInfo/VGGNet"
,
graph
=
tf
.
get_default_graph
())
tf
.
reset_default_graph
()
# if __name__ == '__main__':
...
...
exam/step6/VGGNetTest.py
View file @
391051e1
import
os
os
.
environ
[
\
"TF_CPP_MIN_LOG_LEVEL
\
"
]='3'
os
.
environ
[
"TF_CPP_MIN_LOG_LEVEL"
]
=
'3'
import
warnings
warnings
.
filterwarnings
(
'ignore'
)
...
...
exam/step7/InceptionTest.py
View file @
391051e1
import
os
os
.
environ
[
\
"TF_CPP_MIN_LOG_LEVEL
\
"
]='3'
os
.
environ
[
"TF_CPP_MIN_LOG_LEVEL"
]
=
'3'
import
warnings
warnings
.
filterwarnings
(
'ignore'
)
...
...
exam/step8/ResNetTest.py
View file @
391051e1
import
os
os
.
environ
[
\
"TF_CPP_MIN_LOG_LEVEL
\
"
]='3'
os
.
environ
[
"TF_CPP_MIN_LOG_LEVEL"
]
=
'3'
import
warnings
warnings
.
filterwarnings
(
'ignore'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment