Pythonチュートリアル

Automake version mismatch https://stackoverflow.com/questions/39625663/version-mismatch-for-aclocal https://stackoverflow.com/questions/22603163/automake-error-ltmain-sh-not-found configure.ac » LT_INIT libtoolize root@vultr:~/sync/open_jtalk-1.10# aclocal root@vultr:~/sync/open_jtalk-1.10# autoconf root@vultr:~/sync/open_jtalk-1.10# automake root@vultr:~/sync/open_jtalk-1.10# make

AC_SUBST([AM_CXXFLAGS], [-fpic]) ./configure –with-charset=utf-8 –enable-static –enable-shared ./configure –with-charset=utf-8 LDFLAGS=–whole-archive CFLAGS=-fPIC CXXFLAGS=-fPIC ./configure –with-charset=utf-8 CFLAGS=”-fPIC,-Wl,–whole-archive” CXXFLAGS=”-fPIC,-Wl,–whole-archive”

libtoolize && aclocal && autoconf && automake make -B make LDFLAGS=”–whole-archive”

sudo apt-get install libboost-all-dev https://www.xsim.info/articles/BoostPython/How-to-make-Python-module-with-BoostPython.html

unzip boost_1_67_0.zip cd boost_1_67_0 ./bootstrap.sh –with-libraries=python –with-python=python3 –with-python-version=3.7 ./b2 install cxxflags=-fPIC address-model=64 threading=multi link=static runtime-link=shared variant=release search -name libboost_python37.a

export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:$HOME/temp/boost_1_67_0/:/usr/include/python3.7m/” g++ -DPIC -shared -fPIC -o MyModule.so MyModule.cpp libboost_python37.a

https://www.itsupportwale.com/blog/how-to-upgrade-to-python-3-7-on-ubuntu-18-10/ sudo update-alternatives –config python3 sudo apt-get install python3.7-dev

pip3 install –upgrade pip pip3 install tensorflow-cpu

VirtualEnv Activate » ipython kernel install –user –name=AnyName

tensorflow\python\keras\saving\hdf5_format.py

def load_weights_from_hdf5_group(f, layers):

ここにはPythonでよく使う処理をメモしていきます。

if len(weight_values) != len(symbolic_weights):
  raise ValueError('Layer #' + str(k) + ' (named "' + layer.name +
                   '" in the current model) was found to '
                   'correspond to layer ' + name + ' in the save file. '
                   'However the new layer ' + layer.name + ' expects ' +
                   str(len(symbolic_weights)) +
                   ' weights, but the saved weights have ' +
                   str(len(weight_values)) + ' elements.')
else:
  def ToSlice(ends):
    slices =[]

    for end in ends:
        start = 0
        slices.append(slice(start, end))

    return slices

  for i in range(len(weight_values)):
    if weight_values[i].shape != symbolic_weights[i].shape:
      targetshape = symbolic_weights[i].shape
      weight = weight_values[i]
      mag = np.sqrt(np.mean(weight ** 2))

      targetweight = np.random.normal(0.0, mag*0.2, targetshape)
        
      intersection = np.minimum(weight.shape, targetweight.shape)

      slices = ToSlice(intersection)
      print("SURGERY", weight.shape, targetweight.shape)

      if len(weight.shape) == 0:
          targetweight = weight
      else:
          targetweight[slices] = weight[slices]

      weight_values[i] = targetweight
    #print(weight_values[i].shape, symbolic_weights[i].shape)