Skip to content

Commit

Permalink
Improved output for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
feranick committed Oct 21, 2017
1 parent 13be59e commit fce18b8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion SpectraLearnPredict/SpectraLearnPredict/slp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* SpectraLearnPredict
* Perform Machine Learning on Spectroscopy Data.
* version: 20171020a
* version: 20171021a
*
* Uses: Deep Neural Networks, TensorFlow, SVM, PCA, K-Means
*
Expand Down
4 changes: 2 additions & 2 deletions SpectraLearnPredict/SpectraLearnPredict/slp/slp_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ class dnntfDef:

plotMap = config.plotMapDNNTF

shuffleTrainDNNTF = config.shuffleTrainDNNTF
shuffleTestDNNTF = config.shuffleTestDNNTF
shuffleTrain = config.shuffleTrainDNNTF
shuffleTest = config.shuffleTestDNNTF

#*************************************************
# Setup variables and definitions- do not change.
Expand Down
26 changes: 17 additions & 9 deletions SpectraLearnPredict/SpectraLearnPredict/slp/slp_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,7 @@ def input_fn(A, Cl2):
''' Train DNNClassifier model training via TensorFlow-skflow '''
#********************************************************************************
def trainDNNTF2(A, Cl, A_test, Cl_test, Root):
print('==========================================================================\n')
print('\033[1m Running Deep Neural Networks: tf.DNNClassifier - TensorFlow...\033[0m')
print(' Hidden layers:', dnntfDef.hidden_layers)
print(' Optimizer:',dnntfDef.optimizer,
'\n Activation function:',dnntfDef.activation_function,
'\n L2:',dnntfDef.l2_reg_strength,
'\n Dropout:', dnntfDef.dropout_perc)
printInfo()
import tensorflow as tf
import tensorflow.contrib.learn as skflow
from sklearn import preprocessing
Expand Down Expand Up @@ -200,13 +194,13 @@ def trainDNNTF2(A, Cl, A_test, Cl_test, Root):
x={"x": np.array(A)},
y=np.array(Cl2),
num_epochs=None,
shuffle=dnntfDef.shuffleTrainDNNTF)
shuffle=dnntfDef.shuffleTrain)

test_input_fn = tf.estimator.inputs.numpy_input_fn(
x={"x": np.array(A_test)},
y=np.array(Cl2_test),
num_epochs=None,
shuffle=dnntfDef.shuffleTestDNNTF)
shuffle=dnntfDef.shuffleTest)

validation_monitor = [skflow.monitors.ValidationMonitor(input_fn=test_input_fn,
eval_steps=1,
Expand Down Expand Up @@ -236,6 +230,8 @@ def trainDNNTF2(A, Cl, A_test, Cl_test, Root):
print(" Retreaving training model from: ", model_directory,"\n")

accuracy_score = clf.evaluate(input_fn=test_input_fn, steps=1)
printInfo()

print('\n ==================================')
print(' \033[1mtf.DNNCl\033[0m - Accuracy')
print(' ==================================')
Expand All @@ -246,6 +242,18 @@ def trainDNNTF2(A, Cl, A_test, Cl_test, Root):

return clf, le

def printInfo():
print('==========================================================================\n')
print('\033[1m Running Deep Neural Networks: tf.DNNClassifier - TensorFlow...\033[0m')
print(' Optimizer:',dnntfDef.optimizer,
'\n Hidden layers:', dnntfDef.hidden_layers,
'\n Activation function:',dnntfDef.activation_function,
'\n L2:',dnntfDef.l2_reg_strength,
'\n Dropout:', dnntfDef.dropout_perc,
'\n Learning rate:', dnntfDef.learning_rate,
'\n Shuffle Train:', dnntfDef.shuffleTrain,
'\n Shuffle Test:', dnntfDef.shuffleTest,)

#********************************************************************************
''' Predict using tf.estimator.DNNClassifier model via TensorFlow '''
#********************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion SpectraLearnPredict/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
packages=find_packages(),
install_requires=['numpy', 'matplotlib', 'pandas', 'tensorflow', 'scikit-learn'],
entry_points={'gui_scripts' : ['SpectraLearnPredict=SpectraLearnPredict.__main__:main']},
version='20171020a',
version='20171021a',
description='Machine learning for spectral data',
long_description= """ Machine learning for spectral data """,
author='Nicola Ferralis',
Expand Down

0 comments on commit fce18b8

Please sign in to comment.