| // Copyright 2014 Google Inc. All Rights Reserved. | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); | |
| // you may not use this file except in compliance with the License. | |
| // You may obtain a copy of the License at | |
| // | |
| // http://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, |
Twelve Go Best Practices
Francesc Campoy Flores Gopher at Google @francesc http://campoy.cat/+
- Best practices
This script will cycle to the next available audio output device. It can be tied to a hotkey to easily be triggered. This is handy, for example, for swapping between HDMI audio and headphones.
- Download the
audio-device-switch.shscript and place it in/usr/local/bin. - Make the script executable:
sudo chmod 755 /usr/local/bin/audio-device-switch.sh. - Open the Keyboard Shortcuts settings page, add a new shortcut, tell it to execute
audio-device-switch.sh, and set up your shortcut! - Install the
notify-sendlibrary if you want to see a popup notification when the audio device switches:sudo apt install libnotify-bin.
Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.
Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.
Keychron Keyboards on Linux use the hid_apple driver (even in Windows/Android mode), both in Bluetooth and Wired modes.
By default, this driver uses the F-keys as multimedia shortcuts and you have to press Fn + the key to get the usual F1 through F12 keys.
| w1 = embd_emb.linear_1._parameters['weight'].detach().numpy().copy() | |
| w2 = embd_emb.linear_2._parameters['weight'].detach().numpy().copy() | |
| grd = 2*np.dot(loss_tmp_emb,w2) | |
| s = embd_emb.linear_1._parameters['weight'].detach().numpy().copy() | |
| rng = list(x_lin.numpy()) | |
| for i in rng: | |
| s[i] = s[i] - grd[i] | |
| print(f'Updated weight after manual backpropagation \n{s}') |
| class Embedding_embedding(nn.Module): | |
| def __init__(self): | |
| super().__init__() | |
| self.linear_1 = nn.Embedding(5,3) | |
| self.linear_2 = nn.Linear(3,2,bias=False) | |
| def forward(self,x): | |
| x = self.linear_1(x) | |
| x = self.linear_2(x) | |
| return x |
| # -*- coding: utf-8 -*- | |
| # Form implementation generated from reading ui file 'uxdesign.ui' | |
| # | |
| # Created by: PyQt5 UI code generator 5.6 | |
| # | |
| # WARNING! All changes made in this file will be lost! | |
| from PyQt5 import QtCore, QtGui, QtWidgets |