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
model.save("fiepath") | |
model = load_model("filepath", custom_objects={'Linear' : Linear}) |
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
inputs = Input(...) | |
layer_2 = Dense(4, ...)(inputs) | |
layer_3 = Linear(name= "layer_3")(layer_2) | |
layer_4 = Linear(name="layer_4")(layer_3) | |
layer_5 = Linear(name="layer_5")(layer_4) | |
layer_6 = Linear(name="layer_6")(layer_5) | |
output = Dense(...,activation='softmax')(layer_6) | |
model = Model(inputs=inputs, outputs=output) | |
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
class Linear(Layer): | |
def __init__(self, batch_size=64, units=4,**kwargs): | |
super(Linear, self).__init__(**kwargs) | |
) | |
def get_config(self): | |
config = super(Linear, self).get_config() | |
return config | |
def call(self, inputs): |
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
from qiskit.aqua.operators import Z, Y, X | |
from qiskit.aqua.operators import StateFn | |
QUBITS = 4 | |
operatorZ = Z ^ Z ^ Z ^ Z | |
operatorX = X ^ X ^ X ^ X | |
operatorY = Y ^ Y ^ Y ^ Y | |
def quantum_layer(initial_parameters): | |
# expecting parameters to be a numpy array |
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
from collections import Counter | |
from scapy.all import sniff | |
packet_counts = Counter() | |
def custom_action(packet): | |
key = tuple(sorted([packet[0][1].src, packet[0][1].dst])) | |
packet_counts.update([key]) | |
return f"Packet #{sum(packet_counts.values())}: {packet[0][1].src} ==> {packet[0][1].dst}" |
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
import subprocess | |
import os | |
import time | |
import requests | |
def run_command(command): | |
command = command.rstrip() | |
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
import subprocess | |
def run_command(command): | |
command = command.rstrip() | |
try: | |
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True) | |
except Exception as e: | |
output = "Failed to execute command " + str(e) |
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
import subprocess | |
import time | |
import os | |
import sys | |
import signal | |
loaded_files = [] | |
data = "" | |
def run_command(command): |
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
def run_scripts(): | |
current_dir = os.getcwd() | |
for filename in os.listdir(current_dir): | |
if(filename != "setup_server.py" and filename != "downloader.py"): | |
try: | |
dot_index = filename.index(".") | |
extension = filename[dot_index + 1:] | |
if(extension == "py"): | |
command_list = [] | |
command_list.append("python3") |
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
loaded_files = [] | |
def refresh_downloader(): | |
COMMAND = "curl http://192.168.43.38:9000/downloader.py -o downloader.py" | |
run_command(COMMAND) | |
COMMAND = "python3 downloader.py" | |
command_split = COMMAND.split(" ") | |
subprocess.Popen(command_split) | |
os._exit(os.EX_OK) | |
def fetch_directory_list(): |
NewerOlder