Create an assignment operation for each weight on all devices. The
    weight is assigned the value of the copy on the `host_device'.
187986
def create_sync_ops(self, host_device):
    
    sync_ops = []
    host_params = self.params_device[host_device]
    for device, params in (self.params_device).iteritems():
      if device == host_device:
        continue
      for k in self.params_names:
        if isinstance(params[k], tf.Variable):
          sync_ops += [tf.assign(params[k], host_params[k])]
    return sync_ops
1232422
def copy_keys(source, destination, keys=None):
    
    if keys is None:
        keys = destination.keys()
    for k in set(source) & set(keys):
        destination[k] = source[k]
    return destination
542265
def create_demand(self,
                      project_id,
                      facility,
                      plan,
                      operating_system,
                      tags=None,
                      userdata='',
                      hostname=None,
                      count=1):
        
        tags = {} if tags is None else tags
        hostname = self.get_random_hostname() if hostname is None else hostname
        devices = []
        for i in range(1, count + 1):
            new_hostname = hostname if count == 1 else hostname + '-' + str(i)
            self.logger.info('Adding to project %s: %s, %s, %s, %s, %r',
                             project_id,
                             new_hostname,
                             facility,
                             plan,
                             operating_system,
                             tags)
            try:
                device = self.manager.create_device(project_id=project_id,
                                                    hostname=new_hostname,
                                                    facility=facility,
                                                    plan=plan,
                                                    tags=tags,
                                                    userdata=userdata,
                                                    operating_system=operating_system)
                devices.append(device)
            except packet.baseapi.Error as msg:
                raise PacketManagerException(msg)
        return devices
510235
def init_dense_weight(layer):
    '''
    '''
    units = layer.units
    weight = np.eye(units)
    bias = np.zeros(units)
    layer.set_weights(
        (add_noise(weight, np.array([0, 1])), add_noise(bias, np.array([0, 1])))
    )
974864
def create(self, **kwargs):
        ''''''

        self._set_attributes(**kwargs)
        self._check_type()
        pollster(self._check_all_devices_in_sync)()
        dg = self.devices[0].tm.cm.device_groups.device_group
        dg.create(name=self.name, partition=self.partition, type=self.type)
        for device in self.devices:
            self._add_device_to_device_group(device)
            device.tm.sys.config.exec_cmd('save')
        self.ensure_all_devices_in_sync()
477542
def create_port_binding(self, port, host):
        """"""
        if not self.get_instance_type(port):
            return
        for pb_key in self._get_binding_keys(port, host):
            pb_res = MechResource(pb_key, a_const.PORT_BINDING_RESOURCE,
                                  a_const.CREATE)
            self.provision_queue.put(pb_res)
86064
@Override
    public void setWeights(Map<String, INDArray> weights) throws InvalidKerasConfigurationException {
        this.weights = new HashMap<>();


        INDArray W;
        if (weights.containsKey(conf.getKERAS_PARAM_NAME_W()))
            W = weights.get(conf.getKERAS_PARAM_NAME_W());
        else
            throw new InvalidKerasConfigurationException(
                    "Keras SimpleRNN layer does not contain parameter " + conf.getKERAS_PARAM_NAME_W());
        this.weights.put(SimpleRnnParamInitializer.WEIGHT_KEY, W);


        INDArray RW;
        if (weights.containsKey(conf.getKERAS_PARAM_NAME_RW()))
            RW = weights.get(conf.getKERAS_PARAM_NAME_RW());
        else
            throw new InvalidKerasConfigurationException(
                    "Keras SimpleRNN layer does not contain parameter " + conf.getKERAS_PARAM_NAME_RW());
        this.weights.put(SimpleRnnParamInitializer.RECURRENT_WEIGHT_KEY, RW);


        INDArray b;
        if (weights.containsKey(conf.getKERAS_PARAM_NAME_B()))
            b = weights.get(conf.getKERAS_PARAM_NAME_B());
        else
            throw new InvalidKerasConfigurationException(
                    "Keras SimpleRNN layer does not contain parameter " + conf.getKERAS_PARAM_NAME_B());
        this.weights.put(SimpleRnnParamInitializer.BIAS_KEY, b);


        if (weights.size() > NUM_TRAINABLE_PARAMS) {
            Set<String> paramNames = weights.keySet();
            paramNames.remove(conf.getKERAS_PARAM_NAME_B());
            paramNames.remove(conf.getKERAS_PARAM_NAME_W());
            paramNames.remove(conf.getKERAS_PARAM_NAME_RW());
            String unknownParamNames = paramNames.toString();
            log.warn("Attemping to set weights for unknown parameters: "
                    + unknownParamNames.substring(1, unknownParamNames.length() - 1));
        }
    }
14629
def add(self, host_value):
        
        host_obj = self._host_factory(host_value)
        if self._get_match(host_obj) is not None:
            return
        self._add_new(host_obj)
773118
def assign(name, value):
    '''
    
    '''
    ret = {}
    cmd = 'sysctl {0}="{1}"'.format(name, value)
    data = __salt__['cmd.run_all'](cmd)

    # Certain values cannot be set from this console, at the current
    # securelevel or there are other restrictions that prevent us
    # from applying the setting rightaway.
    if re.match(r'^sysctl:.*: Operation not permitted$', data['stderr']) or \
      data['retcode'] != 0:
        raise CommandExecutionError('sysctl failed: {0}'.format(
            data['stderr']))
    new_name, new_value = data['stdout'].split(':', 1)
    ret[new_name] = new_value.split(' -> ')[-1]
    return ret
684588
def device_set(self, device):
		

		if device['id'].startswith('0x'):
			self.device_id = device['id'][2:]
		elif device['id'].startswith('ios:'):
			self.device_id = device['id'].replace(':', '')
		else:
			self.device_id = device['id']
991420
def _set_attributes(self, **kwargs):
        '''
        '''

        self.devices = kwargs['devices'][:]
        self.partition = kwargs['partition']
        self.device_group_name = 'device_trust_group'
        self.device_group_type = 'sync-only'
1362866
function assign( /* target, ... sources */ ) {
    var args = Array.prototype.slice.call(arguments);
    var target = args.shift() || {};

    args.forEach(function (source) {
        Object.keys(source || {}).forEach(function (key) {
            if (['tls', 'auth'].indexOf(key) >= 0 && source[key] && typeof source[key] === 'object') {
                // tls and auth are special keys that need to be enumerated separately
                // other objects are passed as is
                if (!target[key]) {
                    // esnure that target has this key
                    target[key] = {};
                }
                Object.keys(source[key]).forEach(function (subKey) {
                    target[key][subKey] = source[key][subKey];
                });
            } else {
                target[key] = source[key];
            }
        });
    });
    return target;
}
857900
def add_item(self, host, key, value, clock=None, state=0):
        
        if clock is None:
            clock = self.clock
        if self._config.data_type == "items":
            item = {"host": host, "key": key,
                    "value": value, "clock": clock, "state": state}
        elif self._config.data_type == "lld":
            item = {"host": host, "key": key, "clock": clock, "state": state,
                    "value": json.dumps({"data": value})}
        else:
            if self.logger: # pragma: no cover
                self.logger.error("Setup data_type before adding data")
            raise ValueError('Setup data_type before adding data')
        self._items_list.append(item)
389015
def set(self, name, value):
        

        name = str(name)
        if name not in self._properties:
            raise ArgumentError("Unknown property in DeviceModel", name=name)

        self._properties[name] = value
891858
def update_host(self, hostname, key_values, overwrite=True):
        
        default_empty_host = {
            'name': hostname,
            'hostvars': {},
        }
        host_info = self.hosts.get(hostname, default_empty_host)
        util.deepupdate(host_info, key_values, overwrite=overwrite)
        self.hosts[hostname] = host_info
76481
def devices(self, value):
        

        if value is None:
            self._devices = None

        elif isinstance(value, list):
            results = []
            delimiter = ':'

            for device in value:
                if not isinstance(device, six.string_types):
                    raise TypeError("each device must be a str. {0} was passed".format(device))

                occurrences = device.count(delimiter)
                permissions = 'rwm'

                if occurrences is 0:
                    path_on_host = device
                    path_in_container = device

                elif occurrences is 1:
                    path_on_host, path_in_container = device.split(delimiter)

                elif occurrences is 2:
                    path_on_host, path_in_container, permissions = device.split(delimiter)

                    if permissions not in 'rwm':
                        raise ValueError("only permissions supported for devices are any combination of  'r' 'w' 'm'.")
                else:
                    raise ValueError(
                        """When passing devices they must be in one of the
                        following formats: path_on_host, path_on_host:path_in_container,
                        or path_on_host:path_in_container:permissions"""
                    )

                results.append("{0}:{1}:{2}".format(path_on_host, path_in_container, permissions))

            self._devices = results
        else:
            raise TypeError("devices must be a list or None.")
1117234
def _assign(self, assignment):  # type: (Assignment) -> None
        
        self._assignments.append(assignment)
        self._register(assignment)