def do_run_test(): # Rotating and or blurring images to create larger and balanced classes x, y = ia.load_data(128, 15000) # Restore convolutional neural network and build confusion matrix restore_test.run_test(x, y, model_path) # Test the neural network on the hotdog and not_hotdog jpg check.run(model_path) end_time = time.time() print('Total Run Time {}'.format(round(end_time - start_time, 0)))
def do_run_all(): while True: try: epoch_param = input('How many epochs would you like to run? \n') epoch_param = int(epoch_param) except ValueError: print('Please enter valid integer') continue else: break while True: try: learn_param = input( 'What do you want your learning rate would you like to use? \n' ) learn_param = float(learn_param) except ValueError: print('Please enter valid float') else: break # This function will scrape images from Image.net scrape_images.read_images_to_folder() # # Removing all of the invalid or null images rm.remove_invalid(paths) # Rotating and or blurring images to create larger and balanced classes x, y = ia.load_data(128, 15000) # Run convolutional neural network total_loss, accuracy = cnn.run(x, y, epochs=epoch_param, learning_rate=learn_param) # Restore convolutional neural network and build confusion matrix restore_test.run_test(x, y, model_path) # Test the neural network on the hotdog and not_hotdog jpg check.run(model_path) end_time = time.time() print('Total Run Time {}'.format(round(end_time - start_time, 0)))
def main(): if len(sys.argv) < 3: error_message() mode = sys.argv[1] if mode == '-t': if len(sys.argv) != 3: error_message() folder_name = sys.argv[2] if os.path.isdir(folder_name): train.run(folder_name) print(folder_name + ".json created") else: print("Folder does not exist.") elif mode == '-c': if len(sys.argv) != 4: error_message() book_filename = sys.argv[2] author_profile_filename = sys.argv[3] if not book_filename.endswith(".txt"): print("book must be .txt file") exit() if not author_profile_filename.endswith(".json"): print("author profile must be .json file") exit() check.run(book_filename, author_profile_filename) else: error_message()
else: print('存入MongoDB失败....', proxy) return False def run(self, page_cnt): html = self.get_html(str(page_cnt)) if html is not None: proxies = self.parse_ip(html) for proxy in proxies: if proxy is not None: if self.verify_proxy(proxy): try: self.save_to_mongodb(proxy) except ServerSelectionTimeoutError: print('ServerSelectionTimeoutError: Connection refused!') if __name__ == '__main__': logging.debug('---------------------------------------------------------Go!') check.run() app = Kuaidaili() html = app.get_html() page_cnt = app.parse_page_cnt(html) pool = Pool() pool.map(app.run, [i for i in range(1, int(page_cnt) + 1)])
from rpy2.robjects import r as R from check import start_log, check, run, save_grades lab = "ex2" language = "r" possible = 6 record = True # turn on when ready to record grades g = globals() score = start_log(lab, 0, possible, g, record, language) r_source = R['source'] try: m = r_source(lab+'.R') except: pass run("R('testInput = c(\" hello \")')", g) run("R('correctOutput = c(\"hello\")')", g) run("R('functionOutput = rmMultipleBlanks(testInput)')", g) score += check("R('all.equal(correctOutput, functionOutput)')[0]", True, 3, g) run("R('testInput = c(\" hello, world \", \"\\n \\tStat 133 \")')", g) run("R('correctOutput = c(\"hello, world\", \"Stat 133\")')", g) run("R('functionOutput = rmMultipleBlanks(testInput)')", g) score += check("R('all.equal(correctOutput, functionOutput)')[0]", True, 3, g) save_grades(lab, score, possible, record)
# this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # from __future__ import print_function import sys, os base = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0]))) rtems = os.path.dirname(base) sys.path = [rtems] + sys.path try: import check check.run(sys.argv[1:]) except ImportError: print("Incorrect RTEMS Tools installation", file=sys.stderr) sys.exit(1)
from rpy2.robjects import r as R from check import start_log, check, run, save_grades lab = "ex1" language = "r" possible = 6 record = True # turn on when ready to record grades g = globals() score = start_log(lab, 0, possible, g, record, language) r_source = R['source'] try: m = r_source(lab+'.R') except: pass run("R('testInput = c(\"023-45-7890\") ')", g) run("R('correctOutput = c(\"023-45-7890\") ')", g) run("R('functionOutput = extractSecuNum(testInput)')", g) score += check("R('all.equal(correctOutput, functionOutput)')[0]", True, 3, g) run("R('testInput = c( \"For example\", \"023-45-7890\", \"would be a valid value\", \"but 05-09-1995\", \"and 059-2-27 would not be.\", \"Also 011-99-2234 is okay.\") ')", g) run("R('correctOutput = c( \"023-45-7890\", \"011-99-2234\") ')", g) run("R('functionOutput = extractSecuNum(testInput)')", g) score += check("R('all.equal(correctOutput, functionOutput)')[0]", True, 3, g) save_grades(lab, score, possible, record)
from rpy2.robjects import r as R from check import start_log, check, run, save_grades lab = "ex4" language = "r" possible = 6 record = True # turn on when ready to record grades g = globals() score = start_log(lab, 0, possible, g, record, language) r_source = R['source'] try: m = r_source(lab+'.R') except: pass run("R('testInput = factor(c(11,0,40,-1))')", g) run("R('correctOutput = 50')", g) run("R('functionOutput = sumFactor(testInput)')", g) score += check("R('all.equal(correctOutput, functionOutput)')[0]", True, 3, g) run("R('testInput = factor(c(1,0,2,3,2,1,1,1))')", g) run("R('correctOutput = 11')", g) run("R('functionOutput = sumFactor(testInput)')", g) score += check("R('all.equal(correctOutput, functionOutput)')[0]", True, 3, g) save_grades(lab, score, possible, record)
# # RTEMS Tools Project (http://www.rtems.org/) # Copyright 2010-2012 Chris Johns ([email protected]) # All rights reserved. # # This file is part of the RTEMS Tools package in 'rtems-tools'. # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. from __future__ import print_function import sys, os try: import check check.run() except ImportError: print("Incorrect Source Builder installation", file = sys.stderr) sys.exit(1)
lab = "ex5" language = "r" possible = 24 record = True # turn on when ready to record grades g = globals() score = start_log(lab, 0, possible, g, record, language) r_source = R['source'] try: m = r_source(lab+'.R') except: pass run("R('x1 = c(10000, 1:999)')", g) run("R('x2 = c(1:900, rep(NA, 100))')", g) run("R('x3 = c(1:800, rep(NA, 200))')", g) run("R('y = c(1:999, NA)')", g) run("R('naR = 0.5; naC = 0.05')", g) run("R('data = data.frame(X1=x1, X2=x2, X3=x3, X4=y, X5=y, X6=y, X7=y, X8=y, X9=y, X10=y)')", g) run("R('cleanData = data[-c(1,1000), -c(2,3)]')", g) run("R('dfDiag = dfDiagnosis(data, naRow=naR, naCol=naC)')", g) score += check("R('all.equal(class(dfDiag), \\'dfDiagnosis\\')')[0]", True, 3, g) score += check("R('all.equal(length(dfDiag), 6)')[0]", True, 3, g) score += check("R('all.equal(dfDiag$rawData, data)')[0]", True, 3, g) score += check("R('all.equal(dfDiag$thresholds, c(naR,naC))')[0]", True, 3, g) score += check("R('all.equal(dfDiag$badRows, 1000)')[0]", True, 3, g) score += check("R('all.equal(dfDiag$badCols, c(2,3))')[0]", True, 3, g) score += check("R('all.equal(dfDiag$outliers, list(c(1,1)))')[0]", True, 3, g) score += check("R('all.equal(dfDiag$cleanData, cleanData)')[0]", True, 3, g)
from check import start_log, check, run, save_grades lab = "ex3" language = "r" possible = 6 record = True # turn on when ready to record grades g = globals() score = start_log(lab, 0, possible, g, record, language) r_source = R['source'] try: m = r_source(lab+'.R') except: pass run("R('testInput = c(\\'\"line\" \"t\"\\')')", g) run("R('correctOutput = c(\\'\"line\" \"t\"\\')')", g) run("R('functionOutput = keepDoubleQuotesOnly(testInput)')", g) score += check("R('all.equal(correctOutput, functionOutput)')[0]", True, 3, g) run("R('testInput = c(\\'this \"line\" has \"quoted\" \"strings\"\\', \\'theres \"one\" quoted string\\', \\'\"one\" more to follow \"two\"\\', \\'Heres a quote \"\\', \\'\"a\"\"b\"\\')')", g) run("R('correctOutput = c(\\'this \"line\" has \"quoted\" \"strings\"\\', \\'\"one\" more to follow \"two\"\\', \\'\"a\"\"b\"\\')')", g) run("R('functionOutput = keepDoubleQuotesOnly(testInput)')", g) score += check("R('all.equal(correctOutput, functionOutput)')[0]", True, 3, g) save_grades(lab, score, possible, record)