def __init__(self, dim, nNeurons, name=None, outputFullMap=False): if outputFullMap: outdim = nNeurons ** 2 else: outdim = 2 Module.__init__(self, dim, outdim, name) # switch modes self.outputFullMap = outputFullMap # create neurons self.neurons = random.random((nNeurons, nNeurons, dim)) self.difference = zeros(self.neurons.shape) self.winner = zeros(2) self.nInput = dim self.nNeurons = nNeurons self.neighbours = nNeurons self.learningrate = 0.01 self.neighbourdecay = 0.9999 # distance matrix distx, disty = mgrid[0:self.nNeurons, 0:self.nNeurons] self.distmatrix = zeros((self.nNeurons, self.nNeurons, 2)) self.distmatrix[:, :, 0] = distx self.distmatrix[:, :, 1] = disty
def __init__(self, input_size, output_size): Module.__init__(self) self.weight = Tensor(output_size, input_size) self.bias = Tensor(output_size) self.grad_weight = Tensor(output_size, input_size) self.grad_bias = Tensor(output_size) self.reset()
def __init__(self, probability=0.5, scaled=False): assert probability < 1 and probability > 0, 'probability must be (0,1)' Module.__init__(self) self.prob = probability self.train = True self.scaled = scaled self.noise = torch.Tensor()
def __init__(self, output_depth, batch_size=None, input_dim=None, input_depth=None, kernel_size=5, stride_size=2, act='linear', keep_prob=1.0, pad='SAME', name="conv2d"): self.name = name #self.input_tensor = input_tensor Module.__init__(self) self.batch_size = batch_size self.input_dim = input_dim self.input_depth = input_depth self.output_depth = output_depth self.kernel_size = kernel_size self.stride_size = stride_size self.act = act self.keep_prob = keep_prob self.pad = pad
def __init__(self,args): Module.__init__(self,args) self.log_request = args.log_request self.log_response = args.log_response self.log = args.log self.data = args.data self.headers = args.headers
def __init__(self, output_dim, batch_size=None, input_dim=None, act='linear', batch_norm=False, batch_norm_params={ 'momentum': 0.9, 'epsilon': 1e-5, 'training': False, 'name': 'bn' }, keep_prob=tf.constant(1.0), weights_init=tf.truncated_normal_initializer(stddev=0.01), bias_init=tf.constant_initializer(0.0), name="linear"): self.name = name Module.__init__(self) self.input_dim = input_dim self.output_dim = output_dim self.batch_size = batch_size self.act = act self.batch_norm = batch_norm self.batch_norm_params = batch_norm_params self.keep_prob = keep_prob self.weights_init = weights_init self.bias_init = bias_init
def __init__(self, dim, peepholes=False, name=None): """ :arg dim: number of cells :key peepholes: enable peephole connections (from state to gates)? """ self.setArgs(dim=dim, peepholes=peepholes) # Internal buffers, created dynamically: self.bufferlist = [ ('ingate', dim), ('outgate', dim), ('forgetgate', dim), ('ingatex', dim), ('outgatex', dim), ('forgetgatex', dim), ('state', dim), ('ingateError', dim), ('outgateError', dim), ('forgetgateError', dim), ('stateError', dim), ] Module.__init__(self, 4 * dim, dim, name) if self.peepholes: ParameterContainer.__init__(self, dim * 3) self._setParameters(self.params) self._setDerivatives(self.derivs)
def __init__(self, dim, peepholes = False, name = None): """ :arg dim: number of cells :key peepholes: enable peephole connections (from state to gates)? """ self.setArgs(dim = dim, peepholes = peepholes) # Internal buffers, created dynamically: self.bufferlist = [ ('ingate', dim), ('outgate', dim), ('forgetgate', dim), ('ingatex', dim), ('outgatex', dim), ('forgetgatex', dim), ('state', dim), ('ingateError', dim), ('outgateError', dim), ('forgetgateError', dim), ('stateError', dim), ] Module.__init__(self, 4*dim, dim, name) if self.peepholes: ParameterContainer.__init__(self, dim*3) self._setParameters(self.params) self._setDerivatives(self.derivs)
def __init__(self, context): Module.__init__(self, context) self.monitor_is_on = True self.status_label = render.OutlinedTextImg(color="#8888ff", outlinesize=2, size=20) self.bluetooth_address = context.get_config("bluetooth") if len(self.bluetooth_address) == 0: self.bluetooth_address = None # -1=scan failed, 0=not scanned, 1=not found, 2=found self.bluetooth_status = 0
def __init__(self, modules): ''' Constructor Parameters ---------- modules : list, tuple, etc. enumerable. an enumerable collection of instances of class Module ''' Module.__init__(self) self.modules = modules self.name = '_'.join([x.layerName for x in modules])
def __init__(self, context): Module.__init__(self, context) self.img = None self._next_index = 0 self.img_rect = None self._files = [] slideshow_dir = context.get_config("slideshow_dir") for filename in os.listdir(slideshow_dir): full_path = os.path.join(slideshow_dir, filename) if os.path.isfile(full_path): self._files.append(full_path) random.shuffle(self._files)
def __init__(self, config, channel, x, y): """ Constructor. :param config: the set of configs loaded by the simulator :param channel: the channel to which frames are sent :param x: x position :param y: y position """ Module.__init__(self) #Number of slots in the contention window self.window_slots_count = config.get_param(Node.WINDOW_SIZE) #Duration in seconds of the channel listening period self.listening_duration = config.get_param(Node.LISTENING_TIME) #Duration in seconds of each slot self.slot_duration = self.listening_duration # load configuration parameters self.datarate = config.get_param(Node.DATARATE) self.queue_size = config.get_param(Node.QUEUE) self.interarrival = Distribution(config.get_param(Node.INTERARRIVAL)) self.size = Distribution(config.get_param(Node.SIZE)) self.proc_time = Distribution(config.get_param(Node.PROC_TIME)) self.maxsize = config.get_param(Node.MAXSIZE) # queue of packets to be sent self.queue = [] # current state self.state = None self.switch_state(Node.IDLE) # save position self.x = x self.y = y # save channel self.channel = channel #Number of packets being received self.packets_in_air = 0 #Number of window slots we still have to wait before transmitting self.slot_countdown = 0 #First packet in the current sequence of receiving packets self.rx_sequence_first_packet = None #Hook to events in the queue for future manipulation self.end_listenting_event_hook = None self.end_slot_event_hook = None
def __init__(self, medal): Module.__init__(self, "motion detecter") self.medal = medal # use read only self.acc_x = [0.0 for i in range(5)] self.acc_y = [0.0 for i in range(5)] self.acc_z = [0.0 for i in range(5)] self.mag_x = [0.0 for i in range(5)] self.mag_y = [0.0 for i in range(5)] self.mag_z = [0.0 for i in range(5)] # none:0, roll:1, throw_weak:2, throw_strong:3, throw_verystrong:4 self.motion = 0
def __init__ = (self, input_plane, output_plane, kw, kh, dw=1, dh=1, padding=0): Module.__init__(self) self.input_plane = input_plane self.output_plane = output_plane self.dw = dw self.dh = dh self.kw = kw self.kh = kh self.padding = padding self.weight = Tensor(output_plane, input_plane, kh, kw) self.bias = Tensor(output_plane) self.grad_weight = Tensor(output_plane, input_plane, kh, kw) self.grad_bias = Tensor(output_plane) self.reset()
def __init__(self, frame): Module.__init__(self, frame, 'submod0') self.label = QtWidgets.QLabel() #self.label.setGeometry(10,10,100,200) grid = QtWidgets.QGridLayout() self.setLayout(grid) grid.addWidget(self.label, 0, 0, 1, 1) reader = QtGui.QImageReader("Mod2Line.png") image = reader.read() qpixmap = QtGui.QPixmap() qpixmap.convertFromImage(image) self.label.setPixmap(qpixmap) self.changeStateComplete()
def __init__(self, frame): Module.__init__(self, frame, 'submod0') self.label = QtWidgets.QLabel() #self.label.setGeometry(10,10,100,200) grid = QtWidgets.QGridLayout() self.setLayout(grid) grid.addWidget(self.label, 0, 0, 1, 1) reader = QtGui.QImageReader("Mod2Line.png") image = reader.read() qpixmap = QtGui.QPixmap() qpixmap.convertFromImage(image) self.label.setPixmap(qpixmap) self.changeStateComplete()
def __init__(self, context): Module.__init__(self, context) self._gradient = render.Gradient(context.width, self.GRADIENT_SIZE, pygame.Color(0, 0, 0, 0), pygame.Color(0, 0, 0, 255)) self.zip_code = context.get_config("zip_code") if len(self.zip_code) == 0: self.zip_code = self._get_geoip() self.api_key = context.get_config("api_key") self.temp_label = render.OutlinedTextImg(color="#ffffff", outlinesize=2, size=60) self.weather_label = render.OutlinedTextImg(color="#ffffff", outlinesize=2, size=60) self.updated_label = render.TextImg(color="#ffffff", size=20) self.sun_label = render.TextImg(color="#ffffff", size=20) self.temp_f = "" self._updated_time = None self._had_error = False
def __init__(self,args): Module.__init__(self,args) if args.bytes: self.corrupt = corrupt_bytes else: self.corrupt = corrupt_bits self.number = args.number self.percentage = args.percentage self.corrupt_request = args.both or args.request self.corrupt_response = args.both or args.response # To be reproductible if not args.seed is None: random.seed(args.seed)
def __init__(self, frame): Module.__init__(self, frame, 'submod4') self.init = 1 self.background = QtWidgets.QLabel() #self.label.setGeometry(10,10,100,200) grid = QtWidgets.QGridLayout() self.setLayout(grid) grid.addWidget(self.background, 0, 0, 100, 100) reader = QtGui.QImageReader("pie.png") image = reader.read() qpixmap = QtGui.QPixmap() qpixmap.convertFromImage(image) self.label.setPixmap(qpixmap)
def __init__(self, frame): Module.__init__(self, frame, 'submod3') self.stage = 0 self.init = 1 self.posState2 = 0 self.posState1 = 0 self.selectedButton = 1 self.background = QtWidgets.QLabel() self.background1 = QtWidgets.QLabel() self.button1 = QtWidgets.QPushButton() self.button2 = QtWidgets.QPushButton() self.button3 = QtWidgets.QPushButton() self.displayNum = QtWidgets.QLabel() self.select1 = QtWidgets.QLabel() self.select2 = QtWidgets.QLabel() self.select3 = QtWidgets.QLabel() self.stageLabel = QtWidgets.QLabel() grid = QtWidgets.QGridLayout() self.setLayout(grid) ''' self.background = QtWidgets.QLabel() ''' grid.addWidget(self.background, 0, 0, 0, 1) grid.addWidget(self.background1, 0, 0, 1, 0) grid.addWidget(self.button3, 2, 3) grid.addWidget(self.button2, 2, 2) grid.addWidget(self.button1, 2, 1) grid.addWidget(self.select3, 3, 3) grid.addWidget(self.select2, 3, 2) grid.addWidget(self.select1, 3, 1) grid.addWidget(self.displayNum, 1, 1, 1, 2) grid.addWidget(self.stageLabel, 1, 3, 1, 1) reader = QtGui.QImageReader("Mod3Line1.png") image = reader.read() qpixmap = QtGui.QPixmap() qpixmap.convertFromImage(image) self.background.setPixmap(qpixmap) reader = QtGui.QImageReader("Mod3Line2.png") image = reader.read() qpixmap = QtGui.QPixmap() qpixmap.convertFromImage(image) self.background1.setPixmap(qpixmap)
def __init__(self, context): Module.__init__(self, context) self.clockfont = pygame.font.Font("NixieOne-Regular.otf", int(context.height * .65)) color = "white" outline = "black" self.clock = render.MultiColoredTextImg(parts=[ render.OutlinedTextImg(font=self.clockfont, outercolor=outline, color=color, outlinesize=2), render.OutlinedTextImg(font=self.clockfont, outercolor=outline, color="gray", outlinesize=2), render.OutlinedTextImg(font=self.clockfont, outercolor=outline, color=color, outlinesize=2) ]) self.date_label = render.OutlinedTextImg(color="#ffffff", size=60) self.clock.set_text(1, ":") self._i = 0 self.time_x = 0 self.time_y = 0 self.last_minute = -1 random.seed()
def __init__(self, config, channel, x, y): """ Constructor. :param config: the set of configs loaded by the simulator :param channel: the channel to which frames are sent :param x: x position :param y: y position """ Module.__init__(self) # load configuration parameters self.datarate = config.get_param(Node.DATARATE) self.queue_size = config.get_param(Node.QUEUE) self.interarrival = Distribution(config.get_param(Node.INTERARRIVAL)) self.size = Distribution(config.get_param(Node.SIZE)) self.proc_time = Distribution(config.get_param(Node.PROC_TIME)) self.maxsize = config.get_param(Node.MAXSIZE) # queue of packets to be sent self.queue = [] # current state self.state = Node.IDLE self.logger.log_state(self, Node.IDLE) # save position self.x = x self.y = y # save channel self.channel = channel # current packet being either sent or received self.current_pkt = None # count the number of frames currently under reception self.receiving_count = 0 # timeout event used to avoid being stuck in the RX state self.timeout_rx_event = None # timeout used for the p-persistence self.timeout_wt_event = None # time needed to transmit a packet with the maximum size self.packet_max_tx_time = self.maxsize * 8.0 / self.datarate # p-persistence probability [simple carrier sensing] self.p_persistence = float(config.get_param(Node.PERSISTENCE)) # timeout time for the rx timeout event. set as the time needed to # transmit a packet of the maximum size plus a small amount of 10 # microseconds self.timeout_time = self.packet_max_tx_time + 10e-6 # determine the type of propagation.. self.realistic_propagation = config.get_param( Node.PROPAGATION) == "realistic"
def __init__(self, output_depth, phase_train, batch_size=None, input_dim=None, input_depth=None, name="batchNormConv", param_dir=None, epsilon=1e-3, decay=0.5): self.name = name #self.input_tensor = input_tensor Module.__init__(self) #comment (it's done in fwd pass) self.batch_size = batch_size self.input_dim = input_dim self.input_depth = input_depth #kenel params as in convolution self.output_depth = output_depth self.kernel_size = 1 self.stride_size = 1 self.pad = 'SAME' #path to stored weights and biases self.param_dir = param_dir self.beta = tf.Variable(tf.constant(0.0, shape=[output_depth]), name='beta', trainable=True) self.gamma = tf.Variable(tf.constant(1.0, shape=[output_depth]), name='gamma', trainable=True) self.ema = tf.train.ExponentialMovingAverage(decay=decay) self.phase_train = phase_train #self.is_fullyConnected = is_fullyConnected self.epsilon = epsilon
def __init__(self, indim, outdim, peepholes = False, name = None): nrNeurons = outdim self.peep = peepholes # internal buffers: self.ingate = zeros((0,nrNeurons)) self.outgate = zeros((0,nrNeurons)) self.forgetgate = zeros((0,nrNeurons)) self.cell = zeros((0,nrNeurons)) self.ingatex = zeros((0,nrNeurons)) self.outgatex = zeros((0,nrNeurons)) self.forgetgatex = zeros((0,nrNeurons)) self.cellx = zeros((0,nrNeurons)) self.state = zeros((0,nrNeurons)) self.ingateError = zeros((0,nrNeurons)) self.outgateError = zeros((0,nrNeurons)) self.forgetgateError = zeros((0,nrNeurons)) self.stateError = zeros((0,nrNeurons)) self.Sin = zeros((0,indim*nrNeurons)) self.Sforget = zeros((0,indim*nrNeurons)) self.Scell = zeros((0,indim*nrNeurons)) self.SinRec = zeros((0,nrNeurons*nrNeurons)) self.SforgetRec = zeros((0,nrNeurons*nrNeurons)) self.ScellRec = zeros((0,nrNeurons*nrNeurons)) Module.__init__(self, indim, outdim, name) if self.peep: ParameterContainer.__init__(self, nrNeurons*3 + (4*indim+nrNeurons)*nrNeurons) self.Sin_peep = zeros((0,nrNeurons)) self.Sforget_peep = zeros((0,nrNeurons)) self.Scell_peep = zeros((0,nrNeurons)) else: ParameterContainer.__init__(self, (4*indim+nrNeurons)*nrNeurons) self._setParameters(self.params) self._setDerivatives(self.derivs) # transfer functions and their derivatives self.f = sigmoid self.fprime = sigmoidPrime self.g = lambda x: 2*tanh(x) self.gprime = lambda x: 2*tanhPrime(x) self.h = self.g self.hprime = self.gprime
def __init__(self, output_depth, batch_size=None, input_dim = None, input_depth=None, kernel_size=5, stride_size=2, act = 'relu', phrase=True, pad = 'SAME', weights_init= tf.truncated_normal_initializer(stddev=0.01), bias_init= tf.constant_initializer(0.0), name="conv2d"): self.name = name #self.input_tensor = input_tensor Module.__init__(self) self.batch_size = batch_size self.input_dim = input_dim self.input_depth = input_depth self.output_depth = output_depth self.kernel_size = kernel_size self.stride_size = stride_size self.act = act self.phrase = phrase self.pad = pad self.weights_init = weights_init self.bias_init = bias_init
def __init__(self): Module.__init__(self) self.type = bitopt("type code",0xff,0,'40XX', {0x40:'40XX'}) self.id = bitopt("module identification",0x07,0,'ADAM-4050', {0:'ADAM-4050'}) self.attrdict.update({self.type:3,self.id:7}) # Add the 4050's Digital Inputs. id = 0 for di in self.di_list: di_ion = mpx.lib.factory('mpx.ion.adam.digital_in') di_ion.configure({'parent':self, 'name':di, 'id':id}) id += 1 # Add the initial output status, see TODO 1! self.do_status = [0,0,0,0,0,0,0,0] # Add the 4050's Digital Outputs. id = 0 for do in self.do_list: do_ion = mpx.lib.factory('mpx.ion.adam.digital_out') do_ion.configure({'parent':self, 'name':do, 'id':id}) id += 1
def __init__(self, dim, peepholes = False, name = None): self.setArgs(dim = dim, peepholes = peepholes) # Internal buffers: self.bufferlist = [ ('ingate', dim), ('outgate', dim), ('forgetgate', dim), ('ingatex', dim), ('outgatex', dim), ('forgetgatex', dim), ('state', dim), ('ingateError', dim), ('outgateError', dim), ('forgetgateError', dim), ('stateError', dim), ] Module.__init__(self, 4*dim, dim, name) if self.peepholes: ParameterContainer.__init__(self, dim*3) self._setParameters(self.params) self._setDerivatives(self.derivs)
def __init__(self, dim, dimensions=1, peepholes=False, name=None): self.setArgs(dim=dim, peepholes=peepholes, dimensions=dimensions) # Internal buffers: self.bufferlist = [ ("ingate", dim), ("outgate", dim), ("forgetgate", dim * dimensions), ("ingatex", dim), ("outgatex", dim), ("forgetgatex", dim * dimensions), ("state", dim), ("ingateError", dim), ("outgateError", dim), ("forgetgateError", dim * dimensions), ("stateError", dim), ] Module.__init__(self, (3 + 2 * dimensions) * dim, dim * 2, name) if self.peepholes: ParameterContainer.__init__(self, dim * (2 + dimensions)) self._setParameters(self.params) self._setDerivatives(self.derivs)
def __init__(self): Module.__init__(self)
def __init__(self, client): Module.__init__(self, client) self.load_commands()
def __init__(self, client): Module.__init__(self, client) self.tweets = self.load_data('tweets')['links']
def __init__(self, dim, name=None): """Create a layer with dim number of units.""" Module.__init__(self, dim, dim, name=name) self.setArgs(dim=dim)
def __init__(self): Thread.__init__(self) Module.__init__(self)
def __init__(self, name=None): Module.__init__(self, 0, 1, name = name)
def __init__(self, qmf_object=None, dbus_object=None, lib_object=None, impl_object=None): Module.__init__(self, qmf_object, dbus_object, lib_object, impl_object)
def __init__(self, numStates, numActions, name=None): Module.__init__(self, 1, 1, name) self.numStates = numStates self.numActions = numActions self.values = random.random((numStates, numActions))
def __init__(self, context): Module.__init__(self, context) self._plantserver = context.get_config("plant_server") self._red_label = render.OutlinedTextImg(color="red", outlinesize=2, size=60) self._had_error = False self._status = 0
def __init__(self, frame): Module.__init__(self, frame, 'submod2') self.instructions = ['UP','UP','DOWN','DOWN','LEFT','RIGHT','LEFT','RIGHT','BUTTONB','BUTTONA'] self.instruction_index = 0
def __init__(self, frame): Module.__init__(self, frame, 'submod5') self.init = 1 self.stage = 0 self.selectedButton = 1 self.label = QtWidgets.QLabel() self.label1 = QtWidgets.QLabel() self.label2 = QtWidgets.QLabel() self.outline1 = QtWidgets.QLabel() self.outline2 = QtWidgets.QLabel() self.outline3 = QtWidgets.QLabel() self.outline4 = QtWidgets.QLabel() #self.label.setGeometry(10,10,100,200) self.button1 = QtWidgets.QPushButton() self.button2 = QtWidgets.QPushButton() self.button3 = QtWidgets.QPushButton() self.button4 = QtWidgets.QPushButton() self.select1 = QtWidgets.QLabel() self.select2 = QtWidgets.QLabel() self.select3 = QtWidgets.QLabel() self.select4 = QtWidgets.QLabel() grid = QtWidgets.QGridLayout() self.setLayout(grid) grid.addWidget(self.label, 0, 0, 0, 1) grid.addWidget(self.label1, 0, 0, 1, 0) grid.addWidget(self.label2, 4, 0, 1, 0) grid.addWidget(self.outline1, 2, 2) grid.addWidget(self.outline2, 2, 3) grid.addWidget(self.outline3, 3, 2) grid.addWidget(self.outline4, 3, 3) grid.addWidget(self.button1, 2, 2) grid.addWidget(self.button2, 2, 3) grid.addWidget(self.button3, 3, 2) grid.addWidget(self.button4, 3, 3) grid.addWidget(self.select1, 2, 1) grid.addWidget(self.select2, 2, 4) grid.addWidget(self.select3, 3, 1) grid.addWidget(self.select4, 3, 4) reader = QtGui.QImageReader("Mod3Line1.png") image = reader.read() qpixmap = QtGui.QPixmap() qpixmap.convertFromImage(image) self.label.setPixmap(qpixmap) reader = QtGui.QImageReader("Mod3Line2.png") image = reader.read() qpixmap = QtGui.QPixmap() qpixmap.convertFromImage(image) self.label1.setPixmap(qpixmap) reader = QtGui.QImageReader("Mod3Line2.png") image = reader.read() qpixmap = QtGui.QPixmap() qpixmap.convertFromImage(image) self.label2.setPixmap(qpixmap) reader = QtGui.QImageReader("buttonBox.png") image = reader.read() qpixmap = QtGui.QPixmap() qpixmap.convertFromImage(image) self.outline1.setPixmap(qpixmap) self.outline2.setPixmap(qpixmap) self.outline3.setPixmap(qpixmap) self.outline4.setPixmap(qpixmap)
def __init__(self, frame): Module.__init__(self, frame, 'submod1')