Tutorial by Examples

To use a particular set of GPU devices, the CUDA_VISIBLE_DEVICES environment variable can be used: import os os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID" # see issue #152 os.environ["CUDA_VISIBLE_DEVICES"]="0" # Will use only the first GPU device os.en...
from tensorflow.python.client import device_lib print(device_lib.list_local_devices())
By default, TensorFlow pre-allocate the whole memory of the GPU card (which can causes CUDA_OUT_OF_MEMORY warning). To change this, it is possible to change the percentage of memory pre-allocated, using per_process_gpu_memory_fraction config option, A value between 0 and 1 that indicates wh...
This widget is used to display items with hierarchy. For instance, windows explorer can be reproduced in this way. Some nice tables can be also done using treeview widget. Create the widget tree=ttk.Treeview(master) Definition of the columns You can define how many columns, their width and min...
Each x sigil call respective sigil_x definition Defining Custom Sigils defmodule MySigils do #returns the downcasing string if option l is given then returns the list of downcase letters def sigil_l(string,[]), do: String.Casing.downcase(string) def sigil_l(string,[?l]), do: String.Casing...
This is just the other way of writing Multiple OR conditions. This is not the recommended approach because in regular approach when the condition evaluates to true, it stops executing the remaining conditions which save the time of evaluation, unlike this approach which evaluates all conditions firs...
Copy the content into a file and save the file as .iex.exs in your ~ home directory and see the magic. You can also download the file HERE # IEx.configure colors: [enabled: true] # IEx.configure colors: [ eval_result: [ :cyan, :bright ] ] IO.puts IO.ANSI.red_background() <> IO.ANSI.white() ...
import asyncio async def hello_world(): print('Hello World') loop = asyncio.get_event_loop() loop.run_until_complete(hello_world()) loop.close()
By taking Treeview: Basic example, it can be shown how to customize a basic treeview. In this case, we create a style "mystyle.Treeview" with the following code (see the comments to understand what each line does): style = ttk.Style() style.configure("mystyle.Treeview", highli...
A simple OGL 4.0 GLSL shader program that shows the use of a interface block and a uniform block on a Cook-Torrance microfacet light model implementation. The program is executed with a phyton script. To run the script, PyOpenGL and NumPy must be installed. An Interface Block is a group of GLSL in...
The widget ttk.progress is useful when dealing with long computations so that the user knows that the program is running. Following, an example updating a progressbar each 0.5 seconds is given: Function updating the progressbar def progress(currentValue): progressbar["value"]=curren...
from chempy import Substance ferricyanide = Substance.from_formula('Fe(CN)6-3') ferricyanide.composition == {0: -3, 26: 1, 6: 6, 7: 6} True print(ferricyanide.unicode_name) Fe(CN)₆³⁻ print(ferricyanide.latex_name + ", " + ferricyanide.html_name) Fe(CN)_{6}^{3-}, Fe(CN)<sub>6&...
from chempy import balance_stoichiometry # Main reaction in NASA's booster rockets: reac, prod = balance_stoichiometry({'NH4ClO4', 'Al'}, {'Al2O3', 'HCl', 'H2O', 'N2'}) from pprint import pprint pprint(reac) {'Al': 10, 'NH4ClO4': 6} pprint(prod) {'Al2O3': 5, 'H2O': 9, 'HCl': 6, 'N2': 3} ...
from chempy import Equilibrium from sympy import symbols K1, K2, Kw = symbols('K1 K2 Kw') e1 = Equilibrium({'MnO4-': 1, 'H+': 8, 'e-': 5}, {'Mn+2': 1, 'H2O': 4}, K1) e2 = Equilibrium({'O2': 1, 'H2O': 2, 'e-': 4}, {'OH-': 4}, K2) coeff = Equilibrium.eliminate([e1, e2], 'e-') coeff [4, -5...
from chempy import Equilibrium from chempy.chemistry import Species water_autop = Equilibrium({'H2O'}, {'H+', 'OH-'}, 10**-14) # unit "molar" assumed ammonia_prot = Equilibrium({'NH4+'}, {'NH3', 'H+'}, 10**-9.24) # same here from chempy.equilibria import EqSystem substances = ...
from chempy.electrolytes import ionic_strength ionic_strength({'Fe+3': 0.050, 'ClO4-': 0.150}) == .3 True
from chempy import ReactionSystem # The rate constants below are arbitrary rsys = ReactionSystem.from_string("""2 Fe+2 + H2O2 -> 2 Fe+3 + 2 OH-; 42 2 Fe+3 + H2O2 -> 2 Fe+2 + O2 + 2 H+; 17 H+ + OH- -> H2O; 1e10 H2O -> H+ + OH-; 1e-4 Fe+3 + 2 H2O -...
This is how you install the gcloud command-line tool, which is a part of the Google Cloud SDK. $ curl https://sdk.cloud.google.com | bash
Authorize yourself, you will be navigated to Google Sign In page. $ gcloud auth login Initialize or reinitialize the gcloud, you can set your configurations here. $ gcloud init Display information about the current gcloud environment. $ gcloud info Display the list of active SDK configur...
Create a Cloud SQL instance $dsn = "/cloudsql/PROJECT:REGION:INSTANCE;dbname=DATABASE"; $user = "USER"; $password = "PASSWORD"; $db = new PDO($dsn, $user, $password); //Whatever is your favorite MySQL connection method The important part here is /cloudsql/PRO...

Page 1293 of 1336