Example #1
0
    def test_ff(self):
        model = self.init_model()
        x = np.array([[1, 2], [0, 1]])
        expect = np.array([[0.50255597219646853, 0.50255597219646853],\
                           [0.50255297542884314, 0.50255297542884314]])
        output = model.ff(x)
        self.assertTrue(is_matrix_equals(active.active(output), expect), True)

        ##sparse
        model = self.init_model()
        x = sp.csr_matrix([[1, 2], [0, 1]])
        output = model.ff(x)
        self.assertTrue(is_matrix_equals(active.active(output), expect), True)
 def test_ff(self):
     model  = self.init_model();
     x      = np.array([[1,2],[0,1]]);
     expect = np.array([[0.50255597219646853, 0.50255597219646853],\
                        [0.50255297542884314, 0.50255297542884314]]);
     output = model.ff(x);
     self.assertTrue(is_matrix_equals(active.active(output), expect), True);
 
     
     ##sparse
     model  = self.init_model();
     x      = sp.csr_matrix([[1,2],[0,1]]);
     output = model.ff(x);
     self.assertTrue(is_matrix_equals(active.active(output), expect), True);
Example #3
0
def interface():
    """Interface with input error handling."""

    answer = str(
        raw_input("Sedentary lifestyle, little to no exercise?(Y or N):> "))

    if answer.upper() == "Y":
        return sedentary()
    elif answer.upper() == "N":
        answer = str(
            raw_input(
                "Moderately active job or exercise 2 to 3 times per week?(Y or N):> "
            ))

        if answer.upper() == "Y":
            return moderate()
        elif answer.upper() == "N":
            answer = str(
                raw_input(
                    "Active job and exercise 2 to 3 times per week?(Y or N):> "
                ))

            if answer.upper() == "Y":
                return active()
            elif answer.upper() == "N":
                return veryactive()
            else:
                print "Please enter Y for yes or N for no."
                interface()
        else:
            print "Please enter Y for yes or N for no."
            interface()
    else:
        print "Please enter Y for yes or N for no."
        interface()
Example #4
0
def weights_matrix(n, iterations, X_training, Y_training, center='ac', 
                   sample=1, M=None):
    testing = 3
    matrix_of_weights = []
    for i in range(n):
        weights = active.active(X_training, Y_training, iterations, center=center,
                                sample = sample, testing=testing, M=M)[2]
        matrix_of_weights.append(weights)
    return matrix_of_weights
Example #5
0
def process_input():
    # choose scan method
    print("\nChoose your scan method:")
    choise = input("p    : passive scan\na    : active scan\nf    : full (active) network scan"
                   "\n\nMake your choice: ")
    if choise == "p":
        logging.info("Passive detection selected")
        ip = get_ip()
        passive.passive(ip)
    elif choise == "a":
        logging.info("Active detection selected")
        ip = get_ip()
        active.active(ip)
    elif choise == "f":
        logging.info("Full (active) network scan selected")
        ip = get_ip()
        fullNetworkScan.scan_network(ip)
    else:
        logging.info("Help function is showing")
        help.help_function()
    def test_active(self):
        a        = np.array([[1,2],[0,0]]);
        
        # test sgmoid
        standard   = np.array([[0.7310585786300049,0.8807970779778823],[0.5,0.5]]);
        a_sgmoid   = active.active(a);
        self.assertEqual(is_matrix_equals(a_sgmoid, standard), True);
                
        # test linear
        a_linear = active.active(a, 'linear');
        self.assertEqual(is_matrix_equals(a_linear,a), True); 
        
        # test tanh
        a = np.array([[0.1,-0.2],[0,10]]);
        standard = np.array([[0.099667994624955902, -0.197375320224904],\
                             [0                   ,  0.99999999587769262]]);
        a_tanh = active.active(a, "tanh");
        self.assertTrue(is_matrix_equals(a_tanh, standard));

        # test rel
        standard = np.array([[0.1, 0],[0,10]]);
        a_rel = active.active(a, "rel");
        self.assertTrue(is_matrix_equals(a_rel, standard));

        with self.assertRaises(Exception):
            active.active(a,"unknown active_type")
Example #7
0
    def test_active(self):
        a        = np.array([[1.0,2],[0,0],[-1,-2]]);
        
        # test sgmoid
        standard   = np.array([[0.7310585786300049,0.8807970779778823],[0.5,0.5], [0.2689414213699951, 0.11920292202211755]]);
        a_sgmoid   = active.active(a);
        self.assertEqual(is_matrix_equals(a_sgmoid, standard), True);
                
        # test linear
        a_linear = active.active(a, 'linear');
        self.assertEqual(is_matrix_equals(a_linear,a), True); 
        
        # test tanh
        a = np.array([[0.1,-0.2],[0,10]]);
        standard = np.array([[0.099667994624955902, -0.197375320224904],\
                             [0                   ,  0.99999999587769262]]);
        a_tanh = active.active(a, "tanh");
        self.assertTrue(is_matrix_equals(a_tanh, standard));

        # test rel
        standard = np.array([[0.1, 0],[0,10]]);
        a_rel = active.active(a, "relu");
        self.assertTrue(is_matrix_equals(a_rel, standard));

        with self.assertRaises(Exception):
            active.active(a,"unknown active_type")
Example #8
0
def weights_matrix(n,
                   iterations,
                   X_training,
                   Y_training,
                   center='ac',
                   sample=1,
                   M=None):
    testing = 3
    matrix_of_weights = []
    for i in range(n):
        weights = active.active(X_training,
                                Y_training,
                                iterations,
                                center=center,
                                sample=sample,
                                testing=testing,
                                M=M)[2]
        matrix_of_weights.append(weights)
    return matrix_of_weights
Example #9
0
    else:
        await warn_admins(guild)
    return


@client.event
async def on_guild_leave(guild):
    if (str(guild.id) in db['guilds'].keys()):
        db['guilds'].pop(str(guild.id))


@client.event
async def on_message(message):
    if message.author == client.user:
        return
    await rank_msg(message)
    await stat_msg(message)
    await cmd_msg(message)
    await help_msg(message)
    await stop_msg(client, message)
    await ghot_msg(message)
    await lite_msg(message)
    await info_msg(message)
    #admin commands
    await auto_msg(message)
    await reset_msg(client, message)


active()
client.run(os.environ['BOT_TOKEN'])
Example #10
0
 def run(self):
     active.active(config.botcfg['token'])