Skip to content

Commit

Permalink
Fixed TypeError at start of unet or segnet training (#52)
Browse files Browse the repository at this point in the history
* Fixed 'TypeError: Cannot convert 4.999899999999999e-07 to EagerTensor of dtype int64' in training, fixes #39

https://stackoverflow.com/questions/76511182/tensorflow-custom-learning-rate-scheduler-gives-unexpected-eagertensor-type-erro

* --format was deprecated in ruff and replaced wtih --output-format
  • Loading branch information
liebharc authored Dec 1, 2023
1 parent ac6405d commit 57f49d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9']
python-version: ["3.9"]

steps:
- uses: actions/checkout@v3
Expand All @@ -22,7 +22,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache: "pip"
cache-dependency-path: |
setup.py
Expand All @@ -43,4 +43,4 @@ jobs:
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 .
ruff --output-format=github --select=E9,F63,F7,F82 --target-version=py37 .
1 change: 1 addition & 0 deletions oemer/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def __init__(self, init_lr=0.1, warm_up_steps=1000, decay_step=3000, decay_rate=
self.warm_step_size = (init_lr - min_lr) / warm_up_steps

def __call__(self, step):
step = tf.cast(step, tf.float32)
warm_lr = self.min_lr + self.warm_step_size * step

offset = step - self.warm_up_steps
Expand Down

0 comments on commit 57f49d7

Please sign in to comment.